[vlc-commits] [Git][videolan/vlc][master] audiotrack: disable DynamicsProcessing before Android 12

Jean-Baptiste Kempf (@jbk) gitlab at videolan.org
Sun Oct 24 11:42:11 UTC 2021



Jean-Baptiste Kempf pushed to branch master at VideoLAN / VLC


Commits:
639b9d93 by Thomas Guillem at 2021-10-24T10:40:40+00:00
audiotrack: disable DynamicsProcessing before Android 12

cf. videolan/vlc-android#2221

- - - - -


1 changed file:

- modules/audio_output/audiotrack.c


Changes:

=====================================
modules/audio_output/audiotrack.c
=====================================
@@ -239,6 +239,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;
@@ -453,6 +455,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 );
@@ -508,16 +513,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/639b9d93c194ff5f7473aac7603db16c80d94d76

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




More information about the vlc-commits mailing list