[vlc-devel] [PATCH] audiotrack: Add a define to fetch or not native sample rate

Thomas Guillem thomas at gllm.fr
Wed Apr 29 10:22:23 CEST 2015


If activated, most of  the resampling  will be done by VLC.

Deactivated for now since android resampler is better than the ugly module.
---
 modules/audio_output/audiotrack.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/modules/audio_output/audiotrack.c b/modules/audio_output/audiotrack.c
index 0347aee..12fc84a 100644
--- a/modules/audio_output/audiotrack.c
+++ b/modules/audio_output/audiotrack.c
@@ -108,6 +108,10 @@ struct aout_sys_t {
 //#define AUDIOTRACK_USE_FLOAT
 //#define AUDIOTRACK_HW_LATENCY
 
+/* Get AudioTrack native sample rate: if activated, most of  the resampling
+ * will be done by VLC */
+//#define AUDIOTRACK_NATIVE_SAMPLERATE
+
 #define AUDIO_CHAN_TEXT N_("Audio output channels")
 #define AUDIO_CHAN_LONGTEXT N_("Channels available for audio output. " \
     "If the input has more channels than the output, it will be down-mixed. " \
@@ -279,8 +283,10 @@ InitJNIFields( audio_output_t *p_aout )
 
     GET_ID( GetStaticMethodID, AudioTrack.getMinBufferSize, "getMinBufferSize",
             "(III)I", true );
+#ifdef AUDIOTRACK_NATIVE_SAMPLERATE
     GET_ID( GetStaticMethodID, AudioTrack.getNativeOutputSampleRate,
             "getNativeOutputSampleRate",  "(I)I", true );
+#endif
     GET_CONST_INT( AudioTrack.STATE_INITIALIZED, "STATE_INITIALIZED", true );
     GET_CONST_INT( AudioTrack.MODE_STREAM, "MODE_STREAM", true );
     GET_CONST_INT( AudioTrack.ERROR, "ERROR", true );
@@ -831,7 +837,7 @@ Start( audio_output_t *p_aout, audio_sample_format_t *restrict p_fmt )
     JNIEnv *env;
     jobject p_audiotrack = NULL;
     int i_nb_channels, i_max_channels, i_audiotrack_size, i_bytes_per_frame,
-        i_native_rate;
+        i_native_rate = 0;
     unsigned int i_rate;
     bool b_spdif;
 
@@ -853,13 +859,11 @@ Start( audio_output_t *p_aout, audio_sample_format_t *restrict p_fmt )
     }
     else
     {
-        i_native_rate = JNI_AT_CALL_STATIC_INT( getNativeOutputSampleRate,
-                                                jfields.AudioManager.STREAM_MUSIC );
+        if (jfields.AudioTrack.getNativeOutputSampleRate)
+            i_native_rate = JNI_AT_CALL_STATIC_INT( getNativeOutputSampleRate,
+                                                    jfields.AudioManager.STREAM_MUSIC );
         if( i_native_rate <= 0 )
-        {
-            msg_Warn( p_aout, "negative native rate ? Should not happen !" );
             i_native_rate = VLC_CLIP( p_sys->fmt.i_rate, 4000, 48000 );
-        }
     }
 
     /* We can only accept U8, S16N, FL32, and AC3 */
-- 
2.1.4




More information about the vlc-devel mailing list