[vlc-commits] [Git][videolan/vlc][3.0.x] audiotrack: disable DynamicsProcessing before Android 12

Thomas Guillem (@tguillem) gitlab at videolan.org
Tue Oct 26 06:42:56 UTC 2021



Thomas Guillem pushed to branch 3.0.x at VideoLAN / VLC


Commits:
c900a218 by Thomas Guillem at 2021-10-26T06:28:52+00:00
audiotrack: disable DynamicsProcessing before Android 12

cf. videolan/vlc-android#2221

(cherry picked from commit 639b9d93c194ff5f7473aac7603db16c80d94d76)
Signed-off-by: Thomas Guillem <thomas at gllm.fr>

- - - - -


1 changed file:

- modules/audio_output/audiotrack.c


Changes:

=====================================
modules/audio_output/audiotrack.c
=====================================
@@ -227,6 +227,8 @@ static struct
     struct {
         jint ENCODING_PCM_8BIT;
         jint ENCODING_PCM_16BIT;
+        jint ENCODING_PCM_32BIT;
+        bool has_ENCODING_PCM_32BIT;
         jint ENCODING_PCM_FLOAT;
         bool has_ENCODING_PCM_FLOAT;
         jint ENCODING_AC3;
@@ -408,6 +410,9 @@ InitJNIFields( audio_output_t *p_aout, JNIEnv* env )
     GET_CLASS( "android/media/AudioFormat", true );
     GET_CONST_INT( AudioFormat.ENCODING_PCM_8BIT, "ENCODING_PCM_8BIT", true );
     GET_CONST_INT( AudioFormat.ENCODING_PCM_16BIT, "ENCODING_PCM_16BIT", true );
+    GET_CONST_INT( AudioFormat.ENCODING_PCM_32BIT, "ENCODING_PCM_32BIT", false );
+    jfields.AudioFormat.has_ENCODING_PCM_32BIT = field != NULL;
+
 #ifdef AUDIOTRACK_USE_FLOAT
     GET_CONST_INT( AudioFormat.ENCODING_PCM_FLOAT, "ENCODING_PCM_FLOAT",
                    false );
@@ -463,16 +468,24 @@ InitJNIFields( audio_output_t *p_aout, JNIEnv* env )
     jfields.AudioManager.has_ERROR_DEAD_OBJECT = field != NULL;
     GET_CONST_INT( AudioManager.STREAM_MUSIC, "STREAM_MUSIC", true );
 
-    GET_CLASS( "android/media/audiofx/DynamicsProcessing", false );
-    if( clazz )
+    /* Don't use DynamicsProcessing before Android 12 since it may crash
+     * randomly, cf. videolan/vlc-android#2221.
+     *
+     * ENCODING_PCM_32BIT is available on API 31, so test its availability to
+     * check if we are running Android 12 */
+    if( jfields.AudioFormat.has_ENCODING_PCM_32BIT )
     {
-        jfields.DynamicsProcessing.clazz = (jclass) (*env)->NewGlobalRef( env, clazz );
-        CHECK_EXCEPTION( "NewGlobalRef", true );
-        GET_ID( GetMethodID, DynamicsProcessing.ctor, "<init>", "(I)V", true );
-        GET_ID( GetMethodID, DynamicsProcessing.setInputGainAllChannelsTo,
-                "setInputGainAllChannelsTo", "(F)V", true );
-        GET_ID( GetMethodID, DynamicsProcessing.setEnabled,
-                "setEnabled", "(Z)I", true );
+        GET_CLASS( "android/media/audiofx/DynamicsProcessing", false );
+        if( clazz )
+        {
+            jfields.DynamicsProcessing.clazz = (jclass) (*env)->NewGlobalRef( env, clazz );
+            CHECK_EXCEPTION( "NewGlobalRef", true );
+            GET_ID( GetMethodID, DynamicsProcessing.ctor, "<init>", "(I)V", true );
+            GET_ID( GetMethodID, DynamicsProcessing.setInputGainAllChannelsTo,
+                    "setInputGainAllChannelsTo", "(F)V", true );
+            GET_ID( GetMethodID, DynamicsProcessing.setEnabled,
+                    "setEnabled", "(Z)I", true );
+        }
     }
 
 #undef CHECK_EXCEPTION



View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/c900a2183f8988f32e60afdcae3aa398387295f1

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/c900a2183f8988f32e60afdcae3aa398387295f1
You're receiving this email because of your account on code.videolan.org.




More information about the vlc-commits mailing list