libs/gst/base/gstbasesink.c: Don't ever draw a frame that is >10ms late.

Original commit message from CVS:
* libs/gst/base/gstbasesink.c: (gst_base_sink_wait_clock),
(gst_base_sink_do_sync), (gst_base_sink_render_object):
Don't ever draw a frame that is >10ms late.
This commit is contained in:
Wim Taymans 2006-03-06 15:16:23 +00:00
parent bed06b24d8
commit 6367b03096
2 changed files with 34 additions and 6 deletions

View file

@ -1,3 +1,9 @@
2006-03-06 Wim Taymans <wim@fluendo.com>
* libs/gst/base/gstbasesink.c: (gst_base_sink_wait_clock),
(gst_base_sink_do_sync), (gst_base_sink_render_object):
Don't ever draw a frame that is >10ms late.
2006-03-06 Michael Smith <msmith@fluendo.com>
* gst/gstmessage.c: (_gst_message_copy):

View file

@ -681,13 +681,16 @@ out_of_segment:
* release the PREROLL_LOCK so that other threads can interrupt the entry.
*/
static GstClockReturn
gst_base_sink_wait_clock (GstBaseSink * basesink, GstClockTime time)
gst_base_sink_wait_clock (GstBaseSink * basesink, GstClockTime time,
GstClockTimeDiff * jitter)
{
GstClockID id;
GstClockReturn ret;
GstClock *clock;
GstClockTime base_time;
*jitter = 0;
if (G_UNLIKELY (!GST_CLOCK_TIME_IS_VALID (time)))
goto invalid_time;
@ -706,7 +709,7 @@ gst_base_sink_wait_clock (GstBaseSink * basesink, GstClockTime time)
/* release the preroll lock while waiting */
GST_PAD_PREROLL_UNLOCK (basesink->sinkpad);
ret = gst_clock_id_wait (id, NULL);
ret = gst_clock_id_wait (id, jitter);
GST_PAD_PREROLL_LOCK (basesink->sinkpad);
gst_clock_id_unref (id);
@ -750,9 +753,10 @@ no_clock:
*/
static GstFlowReturn
gst_base_sink_do_sync (GstBaseSink * basesink, GstPad * pad,
GstMiniObject * obj)
GstMiniObject * obj, gboolean * late)
{
GstClockTime start, stop;
GstClockTimeDiff jitter;
gboolean syncable;
GstClockReturn status = GST_CLOCK_OK;
@ -797,7 +801,7 @@ again:
/* preroll done, we can sync since we ar in PLAYING now. */
GST_DEBUG_OBJECT (basesink, "waiting for clock");
basesink->end_time = stop;
status = gst_base_sink_wait_clock (basesink, start);
status = gst_base_sink_wait_clock (basesink, start, &jitter);
GST_DEBUG_OBJECT (basesink, "clock returned %d", status);
/* waiting could be interrupted and we can be flushing now */
@ -811,7 +815,14 @@ again:
goto again;
}
if (status == GST_CLOCK_EARLY && jitter > (10 * GST_MSECOND)) {
/* FIXME, update clock stats here and do some QoS */
GST_DEBUG_OBJECT (basesink, "late: jitter!! %" G_GINT64_FORMAT "\n",
jitter);
*late = TRUE;
} else {
*late = FALSE;
}
return GST_FLOW_OK;
@ -845,14 +856,19 @@ gst_base_sink_render_object (GstBaseSink * basesink, GstPad * pad,
{
GstFlowReturn ret = GST_FLOW_OK;
GstBaseSinkClass *bclass;
gboolean late = FALSE;
/* synchronize this object */
ret = gst_base_sink_do_sync (basesink, pad, obj);
ret = gst_base_sink_do_sync (basesink, pad, obj, &late);
if (G_UNLIKELY (ret != GST_FLOW_OK))
goto sync_failed;
/* and now render */
if (G_LIKELY (GST_IS_BUFFER (obj))) {
/* drop late messages unconditionally */
if (late)
goto dropped;
bclass = GST_BASE_SINK_GET_CLASS (basesink);
GST_DEBUG_OBJECT (basesink, "rendering buffer %p", obj);
@ -912,6 +928,12 @@ sync_failed:
return ret;
}
dropped:
{
GST_DEBUG_OBJECT (basesink, "buffer late, dropping, unref object %p", obj);
gst_mini_object_unref (obj);
return GST_FLOW_OK;
}
}
/* with STREAM_LOCK, PREROLL_LOCK