[vlc-commits] audiotracy: always request the timestamp during the syncing phase
Thomas Guillem
git at videolan.org
Tue Dec 1 12:16:17 CET 2020
vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Mon Nov 23 18:04:07 2020 +0100| [ce763c7541fc0007977bfef64c525f3f95ade572] | committer: Thomas Guillem
audiotracy: always request the timestamp during the syncing phase
Don't wait 500ms between 2 requests if we don't have a valid timestamp.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=ce763c7541fc0007977bfef64c525f3f95ade572
---
modules/audio_output/audiotrack.c | 27 +++++++++++++++------------
1 file changed, 15 insertions(+), 12 deletions(-)
diff --git a/modules/audio_output/audiotrack.c b/modules/audio_output/audiotrack.c
index 7182f0b8fe..1cca517e3d 100644
--- a/modules/audio_output/audiotrack.c
+++ b/modules/audio_output/audiotrack.c
@@ -750,8 +750,6 @@ AudioTrack_GetTimestampPositionUs( JNIEnv *env, audio_output_t *p_aout )
/* Fetch an AudioTrack timestamp every AUDIOTIMESTAMP_INTERVAL_US (500ms) */
if( i_now - p_sys->timestamp.i_last_time >= AUDIOTIMESTAMP_INTERVAL_US )
{
- p_sys->timestamp.i_last_time = i_now;
-
if( JNI_AT_CALL_BOOL( getTimestamp, p_sys->timestamp.p_obj ) )
{
p_sys->timestamp.i_frame_us = VLC_TICK_FROM_NS(JNI_AUDIOTIMESTAMP_GET_LONG( nanoTime ));
@@ -764,21 +762,26 @@ AudioTrack_GetTimestampPositionUs( JNIEnv *env, audio_output_t *p_aout )
p_sys->timestamp.i_frame_post_last = i_frame_post_last;
p_sys->timestamp.i_frame_pos = i_frame_post_last
+ (p_sys->timestamp.i_frame_wrap_count << 32);
+
+ /* frame time should be after last play time
+ * frame time shouldn't be in the future
+ * frame time should be less than 10 seconds old */
+ if( p_sys->timestamp.i_frame_us != 0 && p_sys->timestamp.i_frame_pos != 0
+ && p_sys->timestamp.i_frame_us > p_sys->timestamp.i_play_time
+ && i_now > p_sys->timestamp.i_frame_us
+ && ( i_now - p_sys->timestamp.i_frame_us ) <= VLC_TICK_FROM_SEC(10) )
+ p_sys->timestamp.i_last_time = i_now;
+ else
+ {
+ p_sys->timestamp.i_last_time = 0;
+ p_sys->timestamp.i_frame_us = 0;
+ }
}
else
- {
p_sys->timestamp.i_frame_us = 0;
- p_sys->timestamp.i_frame_pos = 0;
- }
}
- /* frame time should be after last play time
- * frame time shouldn't be in the future
- * frame time should be less than 10 seconds old */
- if( p_sys->timestamp.i_frame_us != 0 && p_sys->timestamp.i_frame_pos != 0
- && p_sys->timestamp.i_frame_us > p_sys->timestamp.i_play_time
- && i_now > p_sys->timestamp.i_frame_us
- && ( i_now - p_sys->timestamp.i_frame_us ) <= VLC_TICK_FROM_SEC(10) )
+ if( p_sys->timestamp.i_frame_us != 0 )
{
vlc_tick_t i_time_diff = i_now - p_sys->timestamp.i_frame_us;
jlong i_frames_diff = samples_from_vlc_tick(i_time_diff, p_sys->fmt.i_rate);
More information about the vlc-commits
mailing list