From 5d5dbe9bc0793a699343c5475faf458584db9715 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Sat, 8 Oct 2005 13:39:02 +0000 Subject: [PATCH] gst/base/gstbasesink.c: Prepare for doing QOS. Original commit message from CVS: * gst/base/gstbasesink.c: (gst_base_sink_handle_object), (gst_base_sink_do_sync), (gst_base_sink_handle_buffer): Prepare for doing QOS. --- ChangeLog | 6 ++++++ gst/base/gstbasesink.c | 37 +++++++++++++++++++++---------------- libs/gst/base/gstbasesink.c | 37 +++++++++++++++++++++---------------- 3 files changed, 48 insertions(+), 32 deletions(-) diff --git a/ChangeLog b/ChangeLog index ab9781281b..477726a138 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2005-10-08 Wim Taymans + + * gst/base/gstbasesink.c: (gst_base_sink_handle_object), + (gst_base_sink_do_sync), (gst_base_sink_handle_buffer): + Prepare for doing QOS. + 2005-10-08 Wim Taymans * check/gst/gstbin.c: (GST_START_TEST): diff --git a/gst/base/gstbasesink.c b/gst/base/gstbasesink.c index f70e66aaf8..93a445eb3a 100644 --- a/gst/base/gstbasesink.c +++ b/gst/base/gstbasesink.c @@ -940,10 +940,10 @@ gst_base_sink_wait (GstBaseSink * basesink, GstClockTime time) * 4) wait on the clock, this blocks * 5) unref the clockid again */ -static gboolean +static GstClockReturn gst_base_sink_do_sync (GstBaseSink * basesink, GstBuffer * buffer) { - gboolean result = TRUE; + GstClockReturn result = GST_CLOCK_OK; GstClockTime start, end; GstClockTimeDiff stream_start, stream_end; GstBaseSinkClass *bclass; @@ -998,7 +998,6 @@ gst_base_sink_do_sync (GstBaseSink * basesink, GstBuffer * buffer) /* now do clocking */ if (basesink->clock && basesink->sync) { - GstClockReturn ret; GstClockTime base_time; GST_LOCK (basesink); @@ -1016,13 +1015,11 @@ gst_base_sink_do_sync (GstBaseSink * basesink, GstBuffer * buffer) else basesink->end_time = GST_CLOCK_TIME_NONE; - ret = gst_base_sink_wait (basesink, stream_start + base_time); + result = gst_base_sink_wait (basesink, stream_start + base_time); GST_UNLOCK (basesink); - GST_LOG_OBJECT (basesink, "clock entry done: %d", ret); - if (ret == GST_CLOCK_UNSCHEDULED) - result = FALSE; + GST_LOG_OBJECT (basesink, "clock entry done: %d", result); } done: @@ -1031,7 +1028,7 @@ done: out_of_segment: { GST_LOG_OBJECT (basesink, "buffer skipped, not in segment"); - return FALSE; + return GST_CLOCK_UNSCHEDULED; } } @@ -1102,16 +1099,24 @@ static inline GstFlowReturn gst_base_sink_handle_buffer (GstBaseSink * basesink, GstBuffer * buf) { GstFlowReturn ret = GST_FLOW_OK; - gboolean render; + GstClockReturn status; - render = gst_base_sink_do_sync (basesink, buf); + status = gst_base_sink_do_sync (basesink, buf); + switch (status) { + case GST_CLOCK_EARLY: + GST_DEBUG_OBJECT (basesink, "late frame !"); + /* fallthrough for now */ + case GST_CLOCK_OK: + { + GstBaseSinkClass *bclass; - if (render) { - GstBaseSinkClass *bclass; - - bclass = GST_BASE_SINK_GET_CLASS (basesink); - if (bclass->render) - ret = bclass->render (basesink, buf); + bclass = GST_BASE_SINK_GET_CLASS (basesink); + if (bclass->render) + ret = bclass->render (basesink, buf); + break; + } + default: + break; } GST_DEBUG_OBJECT (basesink, "buffer unref after render %p", basesink, buf); diff --git a/libs/gst/base/gstbasesink.c b/libs/gst/base/gstbasesink.c index f70e66aaf8..93a445eb3a 100644 --- a/libs/gst/base/gstbasesink.c +++ b/libs/gst/base/gstbasesink.c @@ -940,10 +940,10 @@ gst_base_sink_wait (GstBaseSink * basesink, GstClockTime time) * 4) wait on the clock, this blocks * 5) unref the clockid again */ -static gboolean +static GstClockReturn gst_base_sink_do_sync (GstBaseSink * basesink, GstBuffer * buffer) { - gboolean result = TRUE; + GstClockReturn result = GST_CLOCK_OK; GstClockTime start, end; GstClockTimeDiff stream_start, stream_end; GstBaseSinkClass *bclass; @@ -998,7 +998,6 @@ gst_base_sink_do_sync (GstBaseSink * basesink, GstBuffer * buffer) /* now do clocking */ if (basesink->clock && basesink->sync) { - GstClockReturn ret; GstClockTime base_time; GST_LOCK (basesink); @@ -1016,13 +1015,11 @@ gst_base_sink_do_sync (GstBaseSink * basesink, GstBuffer * buffer) else basesink->end_time = GST_CLOCK_TIME_NONE; - ret = gst_base_sink_wait (basesink, stream_start + base_time); + result = gst_base_sink_wait (basesink, stream_start + base_time); GST_UNLOCK (basesink); - GST_LOG_OBJECT (basesink, "clock entry done: %d", ret); - if (ret == GST_CLOCK_UNSCHEDULED) - result = FALSE; + GST_LOG_OBJECT (basesink, "clock entry done: %d", result); } done: @@ -1031,7 +1028,7 @@ done: out_of_segment: { GST_LOG_OBJECT (basesink, "buffer skipped, not in segment"); - return FALSE; + return GST_CLOCK_UNSCHEDULED; } } @@ -1102,16 +1099,24 @@ static inline GstFlowReturn gst_base_sink_handle_buffer (GstBaseSink * basesink, GstBuffer * buf) { GstFlowReturn ret = GST_FLOW_OK; - gboolean render; + GstClockReturn status; - render = gst_base_sink_do_sync (basesink, buf); + status = gst_base_sink_do_sync (basesink, buf); + switch (status) { + case GST_CLOCK_EARLY: + GST_DEBUG_OBJECT (basesink, "late frame !"); + /* fallthrough for now */ + case GST_CLOCK_OK: + { + GstBaseSinkClass *bclass; - if (render) { - GstBaseSinkClass *bclass; - - bclass = GST_BASE_SINK_GET_CLASS (basesink); - if (bclass->render) - ret = bclass->render (basesink, buf); + bclass = GST_BASE_SINK_GET_CLASS (basesink); + if (bclass->render) + ret = bclass->render (basesink, buf); + break; + } + default: + break; } GST_DEBUG_OBJECT (basesink, "buffer unref after render %p", basesink, buf);