[vlc-devel] [PATCH 2/2] audiotrack: add an option for surround

Thomas Guillem thomas at gllm.fr
Tue Apr 7 11:40:13 CEST 2015


Android mediaserver crashes when you output 5.1 PCM @48kHz via Audiotrack with
a lot of QCOM devices due to a SIGSEGV in their resampler. It happens with
Samsung Galaxy Tab 3/4, Galaxy S4/S5 and many other devices.

Therefore, activate surround only via an extra option.
---
 modules/audio_output/audiotrack.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/modules/audio_output/audiotrack.c b/modules/audio_output/audiotrack.c
index bb79d46..46ff446 100644
--- a/modules/audio_output/audiotrack.c
+++ b/modules/audio_output/audiotrack.c
@@ -80,6 +80,11 @@ struct aout_sys_t {
 // TODO: activate getTimestamp for new android versions
 //#define AUDIOTRACK_USE_TIMESTAMP
 
+#define SURROUND_TEXT N_("Surround sound with audiotrack")
+#define SURROUND_LONGTEXT N_(\
+    "Enable surround sound with audiotrack (5.1 or 7.1).")
+#define CFG_PREFIX "audiotrack-"
+
 vlc_module_begin ()
     set_shortname( "AudioTrack" )
     set_description( N_( "Android AudioTrack audio output" ) )
@@ -88,6 +93,8 @@ vlc_module_begin ()
     set_subcategory( SUBCAT_AUDIO_AOUT )
     add_sw_gain()
     add_shortcut( "audiotrack" )
+    add_bool(CFG_PREFIX "surround", false,
+             SURROUND_TEXT, SURROUND_LONGTEXT, true)
     set_callbacks( Open, Close )
 vlc_module_end ()
 
@@ -634,6 +641,8 @@ Start( audio_output_t *p_aout, audio_sample_format_t *restrict p_fmt )
     int i_nb_channels, i_audiotrack_size, i_bytes_per_frame,
         i_native_rate;
     unsigned int i_rate;
+    bool b_surround = var_InheritBool( p_aout, CFG_PREFIX "surround" );
+    bool b_spdif = var_InheritBool( p_aout, "spdif" );
 
     if( !( env = jni_get_env( THREAD_NAME ) ) )
         return VLC_EGENERIC;
@@ -664,8 +673,7 @@ Start( audio_output_t *p_aout, audio_sample_format_t *restrict p_fmt )
                 p_sys->fmt.i_format = VLC_CODEC_S16N;
             break;
         case VLC_CODEC_A52:
-            if( jfields.AudioFormat.has_ENCODING_AC3
-                && var_InheritBool( p_aout, "spdif" ) )
+            if( jfields.AudioFormat.has_ENCODING_AC3 && b_spdif )
                 p_sys->fmt.i_format = VLC_CODEC_SPDIFB;
             else if( jfields.AudioFormat.has_ENCODING_PCM_FLOAT )
                 p_sys->fmt.i_format = VLC_CODEC_FL32;
@@ -681,7 +689,8 @@ Start( audio_output_t *p_aout, audio_sample_format_t *restrict p_fmt )
      * Android will downmix to stereo if audio output doesn't handle 5.1 or 7.1
      */
     i_nb_channels = aout_FormatNbChannels( &p_sys->fmt );
-    if( i_nb_channels > 5 )
+    if( i_nb_channels > 5
+     && ( b_surround || p_sys->fmt.i_format == VLC_CODEC_SPDIFB ) )
     {
         if( i_nb_channels > 7 && jfields.AudioFormat.has_CHANNEL_OUT_SIDE )
             p_sys->fmt.i_physical_channels = AOUT_CHANS_7_1;
-- 
2.1.3




More information about the vlc-devel mailing list