From 9945d7a468c633db389ffb968db2556ab57e0a9f Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Thu, 28 Sep 2006 15:08:15 +0000 Subject: [PATCH] gst-libs/gst/audio/gstbaseaudiosink.c: When we have a timestamp, we can still perform clipping. Original commit message from CVS: * gst-libs/gst/audio/gstbaseaudiosink.c: (gst_base_audio_sink_render): When we have a timestamp, we can still perform clipping. When we have no clock, we must play the sample ASAP. --- ChangeLog | 7 +++++++ gst-libs/gst/audio/gstbaseaudiosink.c | 25 +++++++++++++++++++++---- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index b72e4eec95..da323ee3a9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2006-09-28 Wim Taymans + + * gst-libs/gst/audio/gstbaseaudiosink.c: + (gst_base_audio_sink_render): + When we have a timestamp, we can still perform clipping. + When we have no clock, we must play the sample ASAP. + 2006-09-28 Wim Taymans * gst/audiorate/gstaudiorate.c: (gst_audio_rate_chain): diff --git a/gst-libs/gst/audio/gstbaseaudiosink.c b/gst-libs/gst/audio/gstbaseaudiosink.c index ed7dd55082..b4742e6c21 100644 --- a/gst-libs/gst/audio/gstbaseaudiosink.c +++ b/gst-libs/gst/audio/gstbaseaudiosink.c @@ -514,6 +514,8 @@ gst_base_audio_sink_render (GstBaseSink * bsink, GstBuffer * buf) GstClockTime crate_num; GstClockTime crate_denom; GstClockTime cinternal, cexternal; + GstClock *clock; + gboolean sync; sink = GST_BASE_AUDIO_SINK (bsink); @@ -540,9 +542,9 @@ gst_base_audio_sink_render (GstBaseSink * bsink, GstBuffer * buf) "time %" GST_TIME_FORMAT ", offset %llu, start %" GST_TIME_FORMAT, GST_TIME_ARGS (time), in_offset, GST_TIME_ARGS (bsink->segment.start)); - /* if not valid timestamp or we don't need to sync, try to play + /* if not valid timestamp or we can't clip or sync, try to play * sample ASAP */ - if (!GST_CLOCK_TIME_IS_VALID (time) || !bsink->sync) { + if (!GST_CLOCK_TIME_IS_VALID (time)) { render_offset = gst_base_audio_sink_get_offset (sink); stop = -1; GST_DEBUG_OBJECT (sink, @@ -585,6 +587,22 @@ gst_base_audio_sink_render (GstBaseSink * bsink, GstBuffer * buf) stop = cstop; } + /* figure out how to sync */ + if ((clock = GST_ELEMENT_CLOCK (bsink))) + sync = bsink->sync; + else + sync = FALSE; + + if (!sync) { + /* no sync needed, play sample ASAP */ + render_offset = gst_base_audio_sink_get_offset (sink); + stop = -1; + GST_DEBUG_OBJECT (sink, + "no sync needed. Using render_offset=%" G_GUINT64_FORMAT, + render_offset); + goto no_sync; + } + gst_clock_get_calibration (sink->provided_clock, &cinternal, &cexternal, &crate_num, &crate_denom); @@ -603,12 +621,11 @@ gst_base_audio_sink_render (GstBaseSink * bsink, GstBuffer * buf) ", render offset %llu, samples %lu", GST_TIME_ARGS (render_time), render_offset, samples); - /* 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) { + if (clock != sink->provided_clock) { GST_DEBUG_OBJECT (sink, "no align needed: we are slaved"); goto no_align; } -- 2.34.1