gst-libs/gst/audio/gstbaseaudiosink.c: Resync if the buffer timestamps drift more than a 10th of a second.

Original commit message from CVS:
* gst-libs/gst/audio/gstbaseaudiosink.c:
(gst_base_audio_sink_render):
Resync if the buffer timestamps drift more than a 10th
of a second.
This commit is contained in:
Wim Taymans 2005-08-31 10:57:35 +00:00
parent 13a09b1343
commit 44cc3421a0
2 changed files with 17 additions and 6 deletions

View file

@ -1,3 +1,10 @@
2005-08-31 Wim Taymans <wim@fluendo.com>
* gst-libs/gst/audio/gstbaseaudiosink.c:
(gst_base_audio_sink_render):
Resync if the buffer timestamps drift more than a 10th
of a second.
2005-08-31 Tim-Philipp Müller <tim at centricular dot net> 2005-08-31 Tim-Philipp Müller <tim at centricular dot net>
* sys/v4l/gstv4lsrc.c: (gst_v4lsrc_set_property), * sys/v4l/gstv4lsrc.c: (gst_v4lsrc_set_property),

View file

@ -335,6 +335,8 @@ gst_base_audio_sink_render (GstBaseSink * bsink, GstBuffer * buf)
GstClockTimeDiff render_diff; GstClockTimeDiff render_diff;
GstBaseAudioSink *sink = GST_BASE_AUDIO_SINK (bsink); GstBaseAudioSink *sink = GST_BASE_AUDIO_SINK (bsink);
gint64 diff; gint64 diff;
guint8 *data;
guint size;
/* can't do anything when we don't have the device */ /* can't do anything when we don't have the device */
if (!gst_ring_buffer_is_acquired (sink->ringbuffer)) if (!gst_ring_buffer_is_acquired (sink->ringbuffer))
@ -342,6 +344,8 @@ gst_base_audio_sink_render (GstBaseSink * bsink, GstBuffer * buf)
in_offset = GST_BUFFER_OFFSET (buf); in_offset = GST_BUFFER_OFFSET (buf);
time = GST_BUFFER_TIMESTAMP (buf); time = GST_BUFFER_TIMESTAMP (buf);
data = GST_BUFFER_DATA (buf);
size = GST_BUFFER_SIZE (buf);
GST_DEBUG ("time %" GST_TIME_FORMAT ", offset %llu, start %" GST_TIME_FORMAT, GST_DEBUG ("time %" GST_TIME_FORMAT ", offset %llu, start %" GST_TIME_FORMAT,
GST_TIME_ARGS (time), in_offset, GST_TIME_ARGS (bsink->segment_start)); GST_TIME_ARGS (time), in_offset, GST_TIME_ARGS (bsink->segment_start));
@ -367,16 +371,16 @@ gst_base_audio_sink_render (GstBaseSink * bsink, GstBuffer * buf)
GST_DEBUG ("render time %" GST_TIME_FORMAT ", render offset %llu, diff %lld", GST_DEBUG ("render time %" GST_TIME_FORMAT ", render offset %llu, diff %lld",
GST_TIME_ARGS (render_time), render_offset, diff); GST_TIME_ARGS (render_time), render_offset, diff);
/* FIXME, depends on samplerate... Also the purpose of the OFFSET fields /* we tollerate a 10th of a second diff before we start resyncing. This
* are to detect gaps and dropouts, we might better use them if they are * should be enough to compensate for various rounding errors in the timestamp
* valid. */ * and sample offset position. */
if (diff < 10) { if (diff < sink->ringbuffer->spec.rate / 10) {
/* just align with previous sample then */ /* just align with previous sample then */
render_offset = -1; render_offset = -1;
/* FIXME, can we use the OFFSET field to detect a gap? */
} }
gst_ring_buffer_commit (sink->ringbuffer, render_offset, gst_ring_buffer_commit (sink->ringbuffer, render_offset, data, size);
GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf));
return GST_FLOW_OK; return GST_FLOW_OK;