[vlc-commits] audiotrack: rename InitDelay

Thomas Guillem git at videolan.org
Wed Apr 15 17:27:07 CEST 2015


vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Wed Apr 15 09:41:52 2015 +0200| [1188440ce929e0fc077670f2873e3c475f29102f] | committer: Thomas Guillem

audiotrack: rename InitDelay

Since it only reset PlaybackHeadPosition.
Move i_samples_written initialisation out of this function.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=1188440ce929e0fc077670f2873e3c475f29102f
---

 modules/audio_output/audiotrack.c |   18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/modules/audio_output/audiotrack.c b/modules/audio_output/audiotrack.c
index 655e6a7..37495b6 100644
--- a/modules/audio_output/audiotrack.c
+++ b/modules/audio_output/audiotrack.c
@@ -438,8 +438,13 @@ AudioTrack_GetPosition( JNIEnv *env, audio_output_t *p_aout )
         - p_sys->headpos.i_initial;
 }
 
+/**
+ * Reset AudioTrack position
+ *
+ * Called after flush, or start
+ */
 static void
-AudioTrack_InitDelay( JNIEnv *env, audio_output_t *p_aout )
+AudioTrack_ResetPlaybackHeadPosition( JNIEnv *env, audio_output_t *p_aout )
 {
     aout_sys_t *p_sys = p_aout->sys;
 
@@ -459,7 +464,6 @@ AudioTrack_InitDelay( JNIEnv *env, audio_output_t *p_aout )
             p_sys->headpos.i_initial = JNI_AT_CALL_INT( getPlaybackHeadPosition );
         } while( p_sys->headpos.i_initial != i_last_pos );
     }
-    p_sys->i_samples_written = 0;
     p_sys->headpos.i_last = 0;
     p_sys->headpos.i_wrap_count = 0;
 }
@@ -860,7 +864,8 @@ Start( audio_output_t *p_aout, audio_sample_format_t *restrict p_fmt )
     CHECK_AT_EXCEPTION( "play" );
     p_sys->i_play_time = mdate();
 
-    AudioTrack_InitDelay( env, p_aout );
+    AudioTrack_ResetPlaybackHeadPosition( env, p_aout );
+    p_sys->i_samples_written = 0;
     *p_fmt = p_sys->fmt;
     aout_SoftVolumeStart( p_aout );
 
@@ -919,7 +924,8 @@ AudioTrack_Write( JNIEnv *env, audio_output_t *p_aout, block_t *p_buffer,
     if( i_audiotrack_pos > p_sys->i_samples_written )
     {
         msg_Warn( p_aout, "audiotrack position is ahead. Should NOT happen" );
-        AudioTrack_InitDelay( env, p_aout );
+        AudioTrack_ResetPlaybackHeadPosition( env, p_aout );
+        p_sys->i_samples_written = 0;
         return 0;
     }
     i_samples_pending = p_sys->i_samples_written - i_audiotrack_pos;
@@ -1255,7 +1261,9 @@ Flush( audio_output_t *p_aout, bool b_wait )
         (*env)->DeleteGlobalRef( env, p_sys->p_bytebuffer );
         p_sys->p_bytebuffer = NULL;
     }
-    AudioTrack_InitDelay( env, p_aout );
+
+    AudioTrack_ResetPlaybackHeadPosition( env, p_aout );
+    p_sys->i_samples_written = 0;
 }
 
 static int



More information about the vlc-commits mailing list