mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-24 02:31:03 +00:00
gst-libs/gst/audio/gstbaseaudiosink.c: Buffers with no timestamps get aligned with previous buffers or on underrun, p...
Original commit message from CVS: * gst-libs/gst/audio/gstbaseaudiosink.c: (gst_base_audio_sink_get_offset), (gst_base_audio_sink_render): Buffers with no timestamps get aligned with previous buffers or on underrun, played ASAP.
This commit is contained in:
parent
69f68fa9f6
commit
cfadd55297
2 changed files with 41 additions and 2 deletions
|
@ -1,3 +1,10 @@
|
|||
2005-10-24 Wim Taymans <wim@fluendo.com>
|
||||
|
||||
* gst-libs/gst/audio/gstbaseaudiosink.c:
|
||||
(gst_base_audio_sink_get_offset), (gst_base_audio_sink_render):
|
||||
Buffers with no timestamps get aligned with previous buffers or
|
||||
on underrun, played ASAP.
|
||||
|
||||
2005-10-24 Julien MOUTTE <julien@moutte.net>
|
||||
|
||||
* gst-libs/gst/video/video.h:
|
||||
|
|
|
@ -336,6 +336,38 @@ wrong_state:
|
|||
}
|
||||
}
|
||||
|
||||
static guint64
|
||||
gst_base_audio_sink_get_offset (GstBaseAudioSink * sink)
|
||||
{
|
||||
guint64 sample;
|
||||
gint writeseg, segdone, sps;
|
||||
gint diff;
|
||||
|
||||
/* assume we can append to the previous sample */
|
||||
sample = sink->next_sample;
|
||||
|
||||
sps = sink->ringbuffer->samples_per_seg;
|
||||
|
||||
/* figure out the segment and the offset inside the segment where
|
||||
* the sample should be written. */
|
||||
writeseg = sample / sps;
|
||||
|
||||
/* get the currently processed segment */
|
||||
segdone = g_atomic_int_get (&sink->ringbuffer->segdone)
|
||||
- sink->ringbuffer->segbase;
|
||||
|
||||
/* see how far away it is from the write segment */
|
||||
diff = writeseg - segdone;
|
||||
if (diff < 0) {
|
||||
/* sample would be dropped, position to next playable position */
|
||||
sample = (segdone + 1) * sps;
|
||||
}
|
||||
|
||||
g_print ("diff: %d\n", diff);
|
||||
|
||||
return sample;
|
||||
}
|
||||
|
||||
static GstFlowReturn
|
||||
gst_base_audio_sink_render (GstBaseSink * bsink, GstBuffer * buf)
|
||||
{
|
||||
|
@ -375,7 +407,7 @@ gst_base_audio_sink_render (GstBaseSink * bsink, GstBuffer * buf)
|
|||
GST_TIME_ARGS (time), in_offset, GST_TIME_ARGS (bsink->segment_start));
|
||||
|
||||
if (!GST_CLOCK_TIME_IS_VALID (time)) {
|
||||
render_offset = sink->next_sample;
|
||||
render_offset = gst_base_audio_sink_get_offset (sink);
|
||||
goto no_sync;
|
||||
}
|
||||
|
||||
|
@ -423,7 +455,7 @@ gst_base_audio_sink_render (GstBaseSink * bsink, GstBuffer * buf)
|
|||
|
||||
no_sync:
|
||||
/* clip length based on rate */
|
||||
samples /= ABS (bsink->segment_rate);
|
||||
samples = MIN (samples, samples / ABS (bsink->segment_rate));
|
||||
|
||||
/* the next sample should be current sample and its length */
|
||||
sink->next_sample = render_offset + samples;
|
||||
|
|
Loading…
Reference in a new issue