Commit c84a6b96 authored by Wim Taymans's avatar Wim Taymans
Browse files

gst-libs/gst/audio/gstbaseaudiosink.c: Align samples even if we have roundoff...

gst-libs/gst/audio/gstbaseaudiosink.c: Align samples even if we have roundoff errors in the timestamp conversion.

Original commit message from CVS:
* gst-libs/gst/audio/gstbaseaudiosink.c:
(gst_base_audio_sink_render):
Align samples even if we have roundoff errors in the
timestamp conversion.
parent 82dc411e
2005-07-16 Wim Taymans <wim@fluendo.com>
* gst-libs/gst/audio/gstbaseaudiosink.c:
(gst_base_audio_sink_render):
Align samples even if we have roundoff errors in the
timestamp conversion.
2005-07-16 Wim Taymans <wim@fluendo.com> 2005-07-16 Wim Taymans <wim@fluendo.com>
   
* docs/libs/tmpl/gstringbuffer.sgml: * docs/libs/tmpl/gstringbuffer.sgml:
......
...@@ -322,6 +322,7 @@ gst_base_audio_sink_render (GstBaseSink * bsink, GstBuffer * buf) ...@@ -322,6 +322,7 @@ gst_base_audio_sink_render (GstBaseSink * bsink, GstBuffer * buf)
guint64 render_offset, in_offset; guint64 render_offset, in_offset;
GstClockTime time, render_time; GstClockTime time, render_time;
GstBaseAudioSink *sink = GST_BASE_AUDIO_SINK (bsink); GstBaseAudioSink *sink = GST_BASE_AUDIO_SINK (bsink);
gint64 diff;
/* 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))
...@@ -336,7 +337,7 @@ gst_base_audio_sink_render (GstBaseSink * bsink, GstBuffer * buf) ...@@ -336,7 +337,7 @@ gst_base_audio_sink_render (GstBaseSink * bsink, GstBuffer * buf)
/* samples should be rendered based on their timestamp. All samples /* samples should be rendered based on their timestamp. All samples
* arriving before the discont_start are to be trown away */ * arriving before the discont_start are to be trown away */
/* FIXME, for now we drop the sample completely, we should /* FIXME, for now we drop the sample completely, we should
* in fact clip the sample */ * in fact clip the sample. Same for the segment_stop, actually. */
if (time < bsink->discont_start) if (time < bsink->discont_start)
return GST_FLOW_OK; return GST_FLOW_OK;
...@@ -347,8 +348,19 @@ gst_base_audio_sink_render (GstBaseSink * bsink, GstBuffer * buf) ...@@ -347,8 +348,19 @@ gst_base_audio_sink_render (GstBaseSink * bsink, GstBuffer * buf)
/* and bring the time to the offset in the buffer */ /* and bring the time to the offset in the buffer */
render_offset = render_time * sink->ringbuffer->spec.rate / GST_SECOND; render_offset = render_time * sink->ringbuffer->spec.rate / GST_SECOND;
GST_DEBUG ("render time %" GST_TIME_FORMAT ", render offset %llu", /* roundoff errors in timestamp conversion */
GST_TIME_ARGS (render_time), render_offset); diff = ABS ((gint64) render_offset - (gint64) sink->ringbuffer->next_sample);
GST_DEBUG ("render time %" GST_TIME_FORMAT ", render offset %llu, diff %lld",
GST_TIME_ARGS (render_time), render_offset, diff);
/* FIXME, depends on samplerate... Also the purpose of the OFFSET fields
* are to detect gaps and dropouts, we might better use them if they are
* valid. */
if (diff < 10) {
/* just align with previous sample then */
render_offset = -1;
}
gst_ring_buffer_commit (sink->ringbuffer, render_offset, gst_ring_buffer_commit (sink->ringbuffer, render_offset,
GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf)); GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment