[vlc-commits] audiotrack: factorize resetting of the internal state
Thomas Guillem
git at videolan.org
Wed Jul 8 11:08:12 CEST 2015
vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Wed Jul 8 11:01:15 2015 +0200| [57fa6824a1e98fa466fc04abff9e690d18b886fa] | committer: Thomas Guillem
audiotrack: factorize resetting of the internal state
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=57fa6824a1e98fa466fc04abff9e690d18b886fa
---
modules/audio_output/audiotrack.c | 37 ++++++++++++++++++++++---------------
1 file changed, 22 insertions(+), 15 deletions(-)
diff --git a/modules/audio_output/audiotrack.c b/modules/audio_output/audiotrack.c
index 495bc2c..7ae3d60 100644
--- a/modules/audio_output/audiotrack.c
+++ b/modules/audio_output/audiotrack.c
@@ -506,6 +506,25 @@ AudioTrack_ResetPositions( JNIEnv *env, audio_output_t *p_aout )
}
/**
+ * Reset all AudioTrack positions and internal state
+ */
+static void
+AudioTrack_Reset( JNIEnv *env, audio_output_t *p_aout )
+{
+ aout_sys_t *p_sys = p_aout->sys;
+
+ if( p_sys->p_bytebuffer )
+ {
+ (*env)->DeleteGlobalRef( env, p_sys->p_bytebuffer );
+ p_sys->p_bytebuffer = NULL;
+ }
+
+ AudioTrack_ResetPositions( env, p_aout );
+ AudioTrack_ResetPlaybackHeadPosition( env, p_aout );
+ p_sys->i_samples_written = 0;
+}
+
+/**
* Get a smooth AudioTrack position
*
* This function smooth out the AudioTrack position since it has a very bad
@@ -1030,12 +1049,10 @@ Start( audio_output_t *p_aout, audio_sample_format_t *restrict p_fmt )
p_sys->i_write_type = WRITE;
}
+ AudioTrack_Reset( env, p_aout );
JNI_AT_CALL_VOID( play );
CHECK_AT_EXCEPTION( "play" );
- AudioTrack_ResetPositions( env, p_aout );
- AudioTrack_ResetPlaybackHeadPosition( env, p_aout );
- p_sys->i_samples_written = 0;
*p_fmt = p_sys->fmt;
aout_SoftVolumeStart( p_aout );
@@ -1385,9 +1402,9 @@ Pause( audio_output_t *p_aout, bool b_pause, mtime_t i_date )
CHECK_AT_EXCEPTION( "pause" );
} else
{
+ AudioTrack_ResetPositions( env, p_aout );
JNI_AT_CALL_VOID( play );
CHECK_AT_EXCEPTION( "play" );
- AudioTrack_ResetPositions( env, p_aout );
}
}
@@ -1438,19 +1455,9 @@ Flush( audio_output_t *p_aout, bool b_wait )
return;
}
}
-
+ AudioTrack_Reset( env, p_aout );
JNI_AT_CALL_VOID( play );
CHECK_AT_EXCEPTION( "play" );
-
- if( p_sys->p_bytebuffer )
- {
- (*env)->DeleteGlobalRef( env, p_sys->p_bytebuffer );
- p_sys->p_bytebuffer = NULL;
- }
-
- AudioTrack_ResetPositions( env, p_aout );
- AudioTrack_ResetPlaybackHeadPosition( env, p_aout );
- p_sys->i_samples_written = 0;
}
static int
More information about the vlc-commits
mailing list