[vlc-commits] [Git][videolan/vlc][master] 2 commits: aout: move vlc_aout_stream_RequestRetiming up
Thomas Guillem (@tguillem)
gitlab at videolan.org
Wed Apr 6 12:40:24 UTC 2022
Thomas Guillem pushed to branch master at VideoLAN / VLC
Commits:
b92f4f50 by Thomas Guillem at 2022-04-06T12:24:18+00:00
aout: move vlc_aout_stream_RequestRetiming up
To avoid forward declarations (in the next commit).
- - - - -
02293b1d by Thomas Guillem at 2022-04-06T12:24:18+00:00
aout: remove timing_report event
Not used by any modules, and not thread-safe.
- - - - -
4 changed files:
- include/vlc_aout.h
- src/audio_output/aout_internal.h
- src/audio_output/dec.c
- src/audio_output/output.c
Changes:
=====================================
include/vlc_aout.h
=====================================
@@ -125,7 +125,6 @@
*/
struct vlc_audio_output_events {
- void (*timing_report)(audio_output_t *, vlc_tick_t system_now, vlc_tick_t pts);
void (*drained_report)(audio_output_t *);
void (*volume_report)(audio_output_t *, float);
void (*mute_report)(audio_output_t *, bool);
=====================================
src/audio_output/aout_internal.h
=====================================
@@ -152,8 +152,6 @@ void vlc_aout_stream_NotifyDrained(vlc_aout_stream *stream);
void vlc_aout_stream_NotifyGain(vlc_aout_stream *stream, float gain);
void vlc_aout_stream_RequestRestart(vlc_aout_stream *stream, unsigned);
-void vlc_aout_stream_RequestRetiming(vlc_aout_stream *stream, vlc_tick_t system_ts,
- vlc_tick_t audio_ts);
void aout_InputRequestRestart(audio_output_t *aout);
=====================================
src/audio_output/dec.c
=====================================
@@ -365,59 +365,8 @@ static void stream_Silence (vlc_aout_stream *stream, vlc_tick_t length, vlc_tick
aout->play(aout, block, system_pts);
}
-static void stream_Synchronize(vlc_aout_stream *stream, vlc_tick_t system_now,
- vlc_tick_t dec_pts)
-{
- /**
- * Depending on the drift between the actual and intended playback times,
- * the audio core may ignore the drift, trigger upsampling or downsampling,
- * insert silence or even discard samples.
- * Future VLC versions may instead adjust the input rate.
- *
- * The audio output plugin is responsible for estimating its actual
- * playback time, or rather the estimated time when the next sample will
- * be played. (The actual playback time is always the current time, that is
- * to say vlc_tick_now(). It is not an useful statistic.)
- *
- * Most audio output plugins can estimate the delay until playback of
- * the next sample to be written to the buffer, or equally the time until
- * all samples in the buffer will have been played. Then:
- * pts = vlc_tick_now() + delay
- */
- vlc_tick_t delay;
- audio_output_t *aout = aout_stream_aout(stream);
-
- if (aout_TimeGet(aout, &delay) != 0)
- return; /* nothing can be done if timing is unknown */
-
- if (stream->sync.discontinuity)
- {
- /* Chicken-egg situation for most aout modules that can't be started
- * deferred (all except PulseAudio). These modules will start to play
- * data immediately and ignore the given play_date (that take the clock
- * jitter into account). We don't want to let vlc_aout_stream_RequestRetiming()
- * handle the first silence (from the "Early audio output" case) since
- * this function will first update the clock without taking the jitter
- * into account. Therefore, we manually insert silence that correspond
- * to the clock jitter value before updating the clock.
- */
- vlc_tick_t play_date =
- vlc_clock_ConvertToSystem(stream->sync.clock, system_now + delay,
- dec_pts, stream->sync.rate);
- vlc_tick_t jitter = play_date - system_now;
- if (jitter > 0)
- {
- stream_Silence(stream, jitter, dec_pts - delay);
- if (aout_TimeGet(aout, &delay) != 0)
- return;
- }
- }
-
- vlc_aout_stream_RequestRetiming(stream, system_now + delay, dec_pts);
-}
-
-void vlc_aout_stream_RequestRetiming(vlc_aout_stream *stream, vlc_tick_t system_ts,
- vlc_tick_t audio_ts)
+static void stream_RequestRetiming(vlc_aout_stream *stream, vlc_tick_t system_ts,
+ vlc_tick_t audio_ts)
{
aout_owner_t *owner = aout_stream_owner(stream);
audio_output_t *aout = aout_stream_aout(stream);
@@ -521,6 +470,57 @@ void vlc_aout_stream_RequestRetiming(vlc_aout_stream *stream, vlc_tick_t system_
}
}
+static void stream_Synchronize(vlc_aout_stream *stream, vlc_tick_t system_now,
+ vlc_tick_t dec_pts)
+{
+ /**
+ * Depending on the drift between the actual and intended playback times,
+ * the audio core may ignore the drift, trigger upsampling or downsampling,
+ * insert silence or even discard samples.
+ * Future VLC versions may instead adjust the input rate.
+ *
+ * The audio output plugin is responsible for estimating its actual
+ * playback time, or rather the estimated time when the next sample will
+ * be played. (The actual playback time is always the current time, that is
+ * to say vlc_tick_now(). It is not an useful statistic.)
+ *
+ * Most audio output plugins can estimate the delay until playback of
+ * the next sample to be written to the buffer, or equally the time until
+ * all samples in the buffer will have been played. Then:
+ * pts = vlc_tick_now() + delay
+ */
+ vlc_tick_t delay;
+ audio_output_t *aout = aout_stream_aout(stream);
+
+ if (aout_TimeGet(aout, &delay) != 0)
+ return; /* nothing can be done if timing is unknown */
+
+ if (stream->sync.discontinuity)
+ {
+ /* Chicken-egg situation for most aout modules that can't be started
+ * deferred (all except PulseAudio). These modules will start to play
+ * data immediately and ignore the given play_date (that take the clock
+ * jitter into account). We don't want to let stream_RequestRetiming()
+ * handle the first silence (from the "Early audio output" case) since
+ * this function will first update the clock without taking the jitter
+ * into account. Therefore, we manually insert silence that correspond
+ * to the clock jitter value before updating the clock.
+ */
+ vlc_tick_t play_date =
+ vlc_clock_ConvertToSystem(stream->sync.clock, system_now + delay,
+ dec_pts, stream->sync.rate);
+ vlc_tick_t jitter = play_date - system_now;
+ if (jitter > 0)
+ {
+ stream_Silence(stream, jitter, dec_pts - delay);
+ if (aout_TimeGet(aout, &delay) != 0)
+ return;
+ }
+ }
+
+ stream_RequestRetiming(stream, system_now + delay, dec_pts);
+}
+
/*****************************************************************************
* vlc_aout_stream_Play : filter & mix the decoded buffer
*****************************************************************************/
=====================================
src/audio_output/output.c
=====================================
@@ -63,14 +63,6 @@ static int var_CopyDevice (vlc_object_t *src, const char *name,
return var_Set (dst, "audio-device", value);
}
-static void aout_TimingNotify(audio_output_t *aout, vlc_tick_t system_ts,
- vlc_tick_t audio_ts)
-{
- aout_owner_t *owner = aout_owner (aout);
- assert(owner->main_stream);
- vlc_aout_stream_RequestRetiming(owner->main_stream, system_ts, audio_ts);
-}
-
static void aout_DrainedNotify(audio_output_t *aout)
{
aout_owner_t *owner = aout_owner (aout);
@@ -176,7 +168,6 @@ static int aout_GainNotify (audio_output_t *aout, float gain)
}
static const struct vlc_audio_output_events aout_events = {
- aout_TimingNotify,
aout_DrainedNotify,
aout_VolumeNotify,
aout_MuteNotify,
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/da10267380f046c6af34bdd8f586fedfd24fd4d5...02293b1df3581f21be77b639153ad16207d94bec
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/da10267380f046c6af34bdd8f586fedfd24fd4d5...02293b1df3581f21be77b639153ad16207d94bec
You're receiving this email because of your account on code.videolan.org.
VideoLAN code repository instance
More information about the vlc-commits
mailing list