vlc | branch: master | Thomas Guillem <[email protected]> | Thu Feb 28 16:44:31 2019 +0100| [9d4bad0da0f49033ed0efaa961066d1187ac5780] | committer: Thomas Guillem
aout: use original pts as play date This will be required by the new vlc_clock_t. Indeed, in case of rate change, only the filters are changed but not the aout. This means that aout->time_get() timebase need to be the same than clock update points: the orignal pts given by the decoder. In case the filters are outputting slightly more or less data because of a ressampler imprecision, the delay will be corrected via a future aout->time_get() call. > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=9d4bad0da0f49033ed0efaa961066d1187ac5780 --- src/audio_output/aout_internal.h | 1 + src/audio_output/dec.c | 20 ++++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/audio_output/aout_internal.h b/src/audio_output/aout_internal.h index 32be61034f..5b302a5d93 100644 --- a/src/audio_output/aout_internal.h +++ b/src/audio_output/aout_internal.h @@ -67,6 +67,7 @@ typedef struct int resamp_type; /**< Resampler mode (FIXME: redundant / resampling) */ bool discontinuity; } sync; + vlc_tick_t original_pts; int requested_stereo_mode; /**< Requested stereo mode set by the user */ diff --git a/src/audio_output/dec.c b/src/audio_output/dec.c index 0898487668..81fc4fdef8 100644 --- a/src/audio_output/dec.c +++ b/src/audio_output/dec.c @@ -99,6 +99,7 @@ error: owner->sync.rate = 1.f; owner->sync.resamp_type = AOUT_RESAMPLING_NONE; owner->sync.discontinuity = true; + owner->original_pts = VLC_TICK_INVALID; atomic_init (&owner->buffers_lost, 0); atomic_init (&owner->buffers_played, 0); @@ -352,7 +353,10 @@ int aout_DecPlay(audio_output_t *aout, block_t *block) goto drop; /* Pipeline is unrecoverably broken :-( */ if (block->i_flags & BLOCK_FLAG_DISCONTINUITY) + { owner->sync.discontinuity = true; + owner->original_pts = VLC_TICK_INVALID; + } if (atomic_load_explicit(&owner->vp.update, memory_order_relaxed)) { @@ -362,6 +366,15 @@ int aout_DecPlay(audio_output_t *aout, block_t *block) vlc_mutex_unlock (&owner->vp.lock); } + if (owner->original_pts == VLC_TICK_INVALID) + { + /* Use the original PTS for synchronization and as a play date of the + * aout module. This PTS need to be saved here in order to use the PTS + * of the first block that has been filtered. Indeed, aout filters may + * need more than one block to output a new one. */ + owner->original_pts = block->i_pts; + } + block = aout_FiltersPlay(owner->filters, block, owner->sync.rate); if (block == NULL) return ret; @@ -370,15 +383,17 @@ int aout_DecPlay(audio_output_t *aout, block_t *block) aout_volume_Amplify (owner->volume, block); /* Drift correction */ - aout_DecSynchronize(aout, block->i_pts); + aout_DecSynchronize(aout, owner->original_pts); /* Output */ owner->sync.discontinuity = false; - aout->play(aout, block, block->i_pts); + aout->play(aout, block, owner->original_pts); + owner->original_pts = VLC_TICK_INVALID; atomic_fetch_add_explicit(&owner->buffers_played, 1, memory_order_relaxed); return ret; drop: owner->sync.discontinuity = true; + owner->original_pts = VLC_TICK_INVALID; block_Release (block); atomic_fetch_add_explicit(&owner->buffers_lost, 1, memory_order_relaxed); return ret; @@ -428,4 +443,5 @@ void aout_DecFlush (audio_output_t *aout, bool wait) aout->flush(aout, wait); } owner->sync.discontinuity = true; + owner->original_pts = VLC_TICK_INVALID; } _______________________________________________ vlc-commits mailing list [email protected] https://mailman.videolan.org/listinfo/vlc-commits
