From 416c011f1148c714b0eb40cb5340de6f36a4f2c5 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Thu, 2 Feb 2006 12:14:35 +0000 Subject: [PATCH] gst-libs/gst/audio/TODO: Updated. Original commit message from CVS: * gst-libs/gst/audio/TODO: Updated. * gst-libs/gst/audio/gstbaseaudiosink.c: (gst_base_audio_sink_drain), (gst_base_audio_sink_event): On EOS, wait till the last sample is played before posting EOS. --- ChangeLog | 9 ++++++++ gst-libs/gst/audio/TODO | 2 -- gst-libs/gst/audio/gstbaseaudiosink.c | 33 +++++++++++++++++++++++++++ 3 files changed, 42 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index f498e88c58..c3b85acb9b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2006-02-02 Wim Taymans + + * gst-libs/gst/audio/TODO: + Updated. + + * gst-libs/gst/audio/gstbaseaudiosink.c: + (gst_base_audio_sink_drain), (gst_base_audio_sink_event): + On EOS, wait till the last sample is played before posting EOS. + 2006-02-01 Philippe Kalaf * gst-libs/gst/rtp/gstbasertpdepayload.c: diff --git a/gst-libs/gst/audio/TODO b/gst-libs/gst/audio/TODO index ac86f802aa..89fdeb6969 100644 --- a/gst-libs/gst/audio/TODO +++ b/gst-libs/gst/audio/TODO @@ -7,8 +7,6 @@ TODO is parsed correctly. - implement seek/query/convert - implement getrange scheduling - - on EOS, only post EOS when the complete ringbuffer has been played. - - more accurate clipping of samples outside of the segment - simple resampling - more accurate master/slave calibration handling - faster audio cutoff when going to PAUSED diff --git a/gst-libs/gst/audio/gstbaseaudiosink.c b/gst-libs/gst/audio/gstbaseaudiosink.c index 61e879066b..9db8f5f72f 100644 --- a/gst-libs/gst/audio/gstbaseaudiosink.c +++ b/gst-libs/gst/audio/gstbaseaudiosink.c @@ -319,6 +319,38 @@ gst_base_audio_sink_get_times (GstBaseSink * bsink, GstBuffer * buffer, *end = GST_CLOCK_TIME_NONE; } +static gboolean +gst_base_audio_sink_drain (GstBaseAudioSink * sink) +{ + if (!sink->ringbuffer) + return TRUE; + if (!sink->ringbuffer->spec.rate) + return TRUE; + + if (sink->next_sample != -1) { + GstClockTime time; + GstClock *clock; + + time = + gst_util_uint64_scale_int (sink->next_sample, GST_SECOND, + sink->ringbuffer->spec.rate); + + GST_OBJECT_LOCK (sink); + if ((clock = GST_ELEMENT_CLOCK (sink)) != NULL) { + GstClockID id = gst_clock_new_single_shot_id (clock, time); + + GST_OBJECT_UNLOCK (sink); + + GST_DEBUG_OBJECT (sink, "waiting for last sample to play"); + gst_clock_id_wait (id, NULL); + sink->next_sample = -1; + } else { + GST_OBJECT_UNLOCK (sink); + } + } + return TRUE; +} + static gboolean gst_base_audio_sink_event (GstBaseSink * bsink, GstEvent * event) { @@ -337,6 +369,7 @@ gst_base_audio_sink_event (GstBaseSink * bsink, GstEvent * event) /* need to start playback when we reach EOS */ gst_ring_buffer_start (sink->ringbuffer); /* now wait till we played everything */ + gst_base_audio_sink_drain (sink); break; default: break;