mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-18 06:16:36 +00:00
gst-libs/gst/audio/gstbaseaudiosink.c: When the audio clock is slaved to another clock, never try to align samples bu...
Original commit message from CVS: * gst-libs/gst/audio/gstbaseaudiosink.c: (gst_base_audio_sink_provide_clock), (gst_base_audio_sink_render): When the audio clock is slaved to another clock, never try to align samples but trust the rate interpolation algorithm.
This commit is contained in:
parent
19cd03c607
commit
f3ae89426a
2 changed files with 42 additions and 26 deletions
|
@ -1,3 +1,10 @@
|
|||
2006-07-24 Wim Taymans <wim@fluendo.com>
|
||||
|
||||
* gst-libs/gst/audio/gstbaseaudiosink.c:
|
||||
(gst_base_audio_sink_provide_clock), (gst_base_audio_sink_render):
|
||||
When the audio clock is slaved to another clock, never try to align
|
||||
samples but trust the rate interpolation algorithm.
|
||||
|
||||
2006-07-24 Wim Taymans <wim@fluendo.com>
|
||||
|
||||
* ext/alsa/gstalsasink.c: (set_hwparams), (gst_alsasink_prepare):
|
||||
|
|
|
@ -200,6 +200,7 @@ gst_base_audio_sink_provide_clock (GstElement * elem)
|
|||
|
||||
return clock;
|
||||
|
||||
/* ERRORS */
|
||||
wrong_state:
|
||||
{
|
||||
GST_DEBUG_OBJECT (sink, "ringbuffer not acquired");
|
||||
|
@ -490,11 +491,6 @@ gst_base_audio_sink_render (GstBaseSink * bsink, GstBuffer * buf)
|
|||
|
||||
sink = GST_BASE_AUDIO_SINK (bsink);
|
||||
|
||||
if (G_UNLIKELY (GST_BUFFER_FLAG_IS_SET (buf, GST_BUFFER_FLAG_DISCONT))) {
|
||||
/* always resync after a discont */
|
||||
sink->next_sample = -1;
|
||||
}
|
||||
|
||||
ringbuf = sink->ringbuffer;
|
||||
|
||||
/* can't do anything when we don't have the device */
|
||||
|
@ -581,8 +577,23 @@ gst_base_audio_sink_render (GstBaseSink * bsink, GstBuffer * buf)
|
|||
", render offset %llu, samples %lu",
|
||||
GST_TIME_ARGS (render_time), render_offset, samples);
|
||||
|
||||
/* roundoff errors in timestamp conversion */
|
||||
if (G_LIKELY (sink->next_sample != -1)) {
|
||||
|
||||
/* never try to align samples when we are slaved to another clock, just
|
||||
* trust the rate control algorithm to align the two clocks. We don't take
|
||||
* the LOCK to read the clock because it does not really matter here and the
|
||||
* clock is not changed while playing normally. */
|
||||
if (GST_ELEMENT_CLOCK (sink) != sink->provided_clock) {
|
||||
GST_DEBUG_OBJECT (sink, "no align needed: we are slaved");
|
||||
goto no_align;
|
||||
}
|
||||
|
||||
/* always resync after a discont */
|
||||
if (G_UNLIKELY (GST_BUFFER_FLAG_IS_SET (buf, GST_BUFFER_FLAG_DISCONT))) {
|
||||
GST_DEBUG_OBJECT (sink, "resync after discont");
|
||||
goto no_align;
|
||||
}
|
||||
|
||||
/* now try to align the sample to the previous one */
|
||||
diff = ABS ((gint64) render_offset - (gint64) sink->next_sample);
|
||||
|
||||
/* we tollerate half a second diff before we start resyncing. This
|
||||
|
@ -597,14 +608,12 @@ gst_base_audio_sink_render (GstBaseSink * bsink, GstBuffer * buf)
|
|||
render_offset = sink->next_sample;
|
||||
} else {
|
||||
/* timestamps drifted apart from previous samples too much, we need to
|
||||
* resync. */
|
||||
GST_WARNING_OBJECT (sink,
|
||||
"resync after discont with previous sample of diff: %lu", diff);
|
||||
}
|
||||
} else {
|
||||
GST_DEBUG_OBJECT (sink, "resync after discont");
|
||||
* resync. We log this as an element warning. */
|
||||
GST_ELEMENT_WARNING (sink, CORE, CLOCK, (NULL),
|
||||
("Unexpected discontinuity in audio timestamps of more than half a second"));
|
||||
}
|
||||
|
||||
no_align:
|
||||
crate =
|
||||
gst_guint64_to_gdouble (crate_num) / gst_guint64_to_gdouble (crate_denom);
|
||||
GST_DEBUG_OBJECT (sink,
|
||||
|
|
Loading…
Reference in a new issue