[vlc-commits] [Git][videolan/vlc][master] audio_output: apply the output delay first
Steve Lhomme (@robUx4)
gitlab at videolan.org
Sat Jul 11 16:43:14 UTC 2026
Steve Lhomme pushed to branch master at VideoLAN / VLC
Commits:
21bc9c47 by Alexandre Janniaux at 2026-07-11T16:30:16+00:00
audio_output: apply the output delay first
The output delay was applied after the block's play_date had already
been converted, so the reconversion when play_date == VLC_TICK_INVALID
was skipped and the first block kept its play_date that didn't account
for the delay.
On a slave clock the delay is folded into play_date by
vlc_clock_slave_to_system(), so the output start_date wasn't accounting
for the delay while every later block carried the delay, producing a
drift equal to the configured delay, triggering the resampler right
after startup.
The audio filters were likewise fed the first block with the stale
delay, since aout_FiltersSetClockDelay() ran after aout_FiltersPlay().
The delay update was introduced after the filters in commit
a3e4cb4a907f5fdbface2c4a1012461fc4382f92, back when the single clock
conversion also happened at the end of the function, after the delay
update, so the delay was correctly reflected in play_date.
This is a regression from 7dc7847c343a7fe27e78a5b100cf773ca8eddbcc, i.e.
"aout: convert pts before filtering the input block", since the
conversion moved before filtering to detect discontinuities, but left
the delay update where it was.
- - - - -
1 changed file:
- src/audio_output/dec.c
Changes:
=====================================
src/audio_output/dec.c
=====================================
@@ -843,6 +843,18 @@ int vlc_aout_stream_Play(vlc_aout_stream *stream, block_t *block)
vlc_tick_t play_date = VLC_TICK_INVALID;
vlc_tick_t system_now;
+ if (stream->sync.request_delay != stream->sync.delay)
+ {
+ stream->sync.delay = stream->sync.request_delay;
+ vlc_clock_Lock(stream->sync.clock);
+ vlc_tick_t delta = vlc_clock_SetDelay(stream->sync.clock, stream->sync.delay);
+ vlc_clock_Unlock(stream->sync.clock);
+ if (stream->filters)
+ aout_FiltersSetClockDelay(stream->filters, stream->sync.delay);
+ if (delta > 0)
+ stream_Silence(stream, delta, block->i_pts);
+ }
+
if (stream->filters && (block->i_flags & BLOCK_FLAG_CORE_PRIVATE_FILTERED) == 0)
{
system_now = vlc_tick_now();
@@ -874,19 +886,6 @@ int vlc_aout_stream_Play(vlc_aout_stream *stream, block_t *block)
if (stream->volume != NULL)
aout_volume_Amplify(stream->volume, block);
- /* Update delay */
- if (stream->sync.request_delay != stream->sync.delay)
- {
- stream->sync.delay = stream->sync.request_delay;
- vlc_clock_Lock(stream->sync.clock);
- vlc_tick_t delta = vlc_clock_SetDelay(stream->sync.clock, stream->sync.delay);
- vlc_clock_Unlock(stream->sync.clock);
- if (stream->filters)
- aout_FiltersSetClockDelay(stream->filters, stream->sync.delay);
- if (delta > 0)
- stream_Silence(stream, delta, block->i_pts);
- }
-
/* Convert the pts if not previously done by filters */
if (play_date == VLC_TICK_INVALID)
{
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/21bc9c4720a22e5a24b1cf96175b6f8f2592b63c
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/21bc9c4720a22e5a24b1cf96175b6f8f2592b63c
You're receiving this email because of your account on code.videolan.org. Manage all notifications: https://code.videolan.org/-/profile/notifications | Help: https://code.videolan.org/help
More information about the vlc-commits
mailing list