[vlc-devel] [PATCH 1/4] audiotrack: refactor AudioTrack_SetVolume

Thomas Guillem thomas at gllm.fr
Tue Dec 1 17:58:34 CET 2020


---
 modules/audio_output/audiotrack.c | 40 +++++++++++++++----------------
 1 file changed, 20 insertions(+), 20 deletions(-)

diff --git a/modules/audio_output/audiotrack.c b/modules/audio_output/audiotrack.c
index 605d76ce365..20ed92bc57a 100644
--- a/modules/audio_output/audiotrack.c
+++ b/modules/audio_output/audiotrack.c
@@ -2119,6 +2119,22 @@ bailout:
     vlc_mutex_unlock( &p_sys->lock );
 }
 
+static void
+AudioTrack_SetVolume( JNIEnv *env, audio_output_t *p_aout, float volume )
+{
+    aout_sys_t *p_sys = p_aout->sys;
+
+    if( jfields.AudioTrack.setVolume )
+    {
+        JNI_AT_CALL_INT( setVolume, volume );
+        CHECK_AT_EXCEPTION( "setVolume" );
+    } else
+    {
+        JNI_AT_CALL_INT( setStereoVolume, volume, volume );
+        CHECK_AT_EXCEPTION( "setStereoVolume" );
+    }
+}
+
 static int
 VolumeSet( audio_output_t *p_aout, float volume )
 {
@@ -2136,16 +2152,9 @@ VolumeSet( audio_output_t *p_aout, float volume )
 
     if( !p_sys->b_error && p_sys->p_audiotrack != NULL && ( env = GET_ENV() ) )
     {
-        if( jfields.AudioTrack.setVolume )
-        {
-            JNI_AT_CALL_INT( setVolume, volume );
-            CHECK_AT_EXCEPTION( "setVolume" );
-        } else
-        {
-            JNI_AT_CALL_INT( setStereoVolume, volume, volume );
-            CHECK_AT_EXCEPTION( "setStereoVolume" );
-        }
+        AudioTrack_SetVolume( env, p_aout, volume );
     }
+
     aout_VolumeReport(p_aout, volume);
     aout_GainRequest(p_aout, gain * gain * gain);
     return 0;
@@ -2159,17 +2168,8 @@ MuteSet( audio_output_t *p_aout, bool mute )
     p_sys->mute = mute;
 
     if( !p_sys->b_error && p_sys->p_audiotrack != NULL && ( env = GET_ENV() ) )
-    {
-        if( jfields.AudioTrack.setVolume )
-        {
-            JNI_AT_CALL_INT( setVolume, mute ? 0.0f : p_sys->volume );
-            CHECK_AT_EXCEPTION( "setVolume" );
-        } else
-        {
-            JNI_AT_CALL_INT( setStereoVolume, mute ? 0.0f : p_sys->volume, mute ? 0.0f : p_sys->volume );
-            CHECK_AT_EXCEPTION( "setStereoVolume" );
-        }
-    }
+        AudioTrack_SetVolume( env, p_aout, mute ? 0.0f : p_sys->volume );
+
     aout_MuteReport(p_aout, mute);
     return 0;
 }
-- 
2.28.0



More information about the vlc-devel mailing list