vlc/vlc-3.0 | branch: master | Alexandre Janniaux 
<alexandre.janni...@gmail.com> | Thu Feb 22 14:42:02 2018 +0100| 
[1a87ff2bba59c94621710a9c66ba40e69515d8e9] | committer: Thomas Guillem

audiotrack: add support for audio session id

Add a module variable to store an audio session id and use it when creating new
AudioTrack. This session id is generated by AudioManager.getAudioSessionId() in
the Android-side. This allows LibVLC users to broadcast intent allowing
external application to plug on the audio output and apply effect, for instance
an external equalizer.

See also android.media.audiofx.AudioEffect.

Signed-off-by: Thomas Guillem <tho...@gllm.fr>
(cherry picked from commit 2717d570f41f0829876a9f43ba4b6f86c2375b6f)
Signed-off-by: Thomas Guillem <tho...@gllm.fr>

> http://git.videolan.org/gitweb.cgi/vlc/vlc-3.0.git/?a=commit;h=1a87ff2bba59c94621710a9c66ba40e69515d8e9
---

 modules/audio_output/audiotrack.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/modules/audio_output/audiotrack.c 
b/modules/audio_output/audiotrack.c
index bacc3fc1b2..238826bb95 100644
--- a/modules/audio_output/audiotrack.c
+++ b/modules/audio_output/audiotrack.c
@@ -179,12 +179,17 @@ struct aout_sys_t {
  * will be done by VLC */
 #define AUDIOTRACK_NATIVE_SAMPLERATE
 
+#define AUDIOTRACK_SESSION_ID_TEXT " Id of audio session the AudioTrack must 
be attached to"
+
 vlc_module_begin ()
     set_shortname( "AudioTrack" )
     set_description( "Android AudioTrack audio output" )
     set_capability( "audio output", 180 )
     set_category( CAT_AUDIO )
     set_subcategory( SUBCAT_AUDIO_AOUT )
+    add_integer( "audiotrack-session-id", 0,
+            AUDIOTRACK_SESSION_ID_TEXT, NULL, true )
+        change_private()
     add_sw_gain()
     add_shortcut( "audiotrack" )
     set_callbacks( Open, Close )
@@ -320,7 +325,7 @@ InitJNIFields( audio_output_t *p_aout, JNIEnv* env )
     jfields.AudioTrack.clazz = (jclass) (*env)->NewGlobalRef( env, clazz );
     CHECK_EXCEPTION( "NewGlobalRef", true );
 
-    GET_ID( GetMethodID, AudioTrack.ctor, "<init>", "(IIIIII)V", true );
+    GET_ID( GetMethodID, AudioTrack.ctor, "<init>", "(IIIIIII)V", true );
     GET_ID( GetMethodID, AudioTrack.release, "release", "()V", true );
     GET_ID( GetMethodID, AudioTrack.getState, "getState", "()I", true );
     GET_ID( GetMethodID, AudioTrack.play, "play", "()V", true );
@@ -815,9 +820,11 @@ AudioTrack_New( JNIEnv *env, audio_output_t *p_aout, 
unsigned int i_rate,
                 int i_channel_config, int i_format, int i_size )
 {
     aout_sys_t *p_sys = p_aout->sys;
+    jint session_id = var_InheritInteger( p_aout, "audiotrack-session-id" );
     jobject p_audiotrack = JNI_AT_NEW( jfields.AudioManager.STREAM_MUSIC,
                                        i_rate, i_channel_config, i_format,
-                                       i_size, jfields.AudioTrack.MODE_STREAM 
);
+                                       i_size, jfields.AudioTrack.MODE_STREAM,
+                                       session_id );
     if( CHECK_AT_EXCEPTION( "AudioTrack<init>" ) || !p_audiotrack )
     {
         msg_Warn( p_aout, "AudioTrack Init failed" ) ;

_______________________________________________
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits

Reply via email to