libs/gst/base/gstbasesink.c: Some cleanups.

Original commit message from CVS:
* libs/gst/base/gstbasesink.c: (gst_base_sink_handle_object),
(gst_base_sink_do_sync):
Some cleanups.
When the sink finishes blocking on the preroll buffer, it can
immediatly render it instead of rendering when the next buffer
arrives.
This commit is contained in:
Wim Taymans 2006-01-18 17:18:39 +00:00
parent 94e1664fca
commit a42ee31bd8

View file

@ -728,36 +728,36 @@ gst_base_sink_handle_object (GstBaseSink * basesink, GstPad * pad,
/* see if we need to block now. We cannot block on events, only /* see if we need to block now. We cannot block on events, only
* on buffers, the reason is that events can be sent from the * on buffers, the reason is that events can be sent from the
* application thread and we don't want to block there. */ * application thread and we don't want to block there. */
if (length > basesink->preroll_queue_max_len && !have_event) { if (length <= basesink->preroll_queue_max_len || have_event)
/* block until the state changes, or we get a flush, or something */ goto more_preroll;
GST_DEBUG_OBJECT (basesink, "waiting to finish preroll");
GST_PAD_PREROLL_WAIT (pad); /* block until the state changes, or we get a flush, or something */
GST_DEBUG_OBJECT (basesink, "done preroll"); GST_DEBUG_OBJECT (basesink, "waiting to finish preroll");
GST_OBJECT_LOCK (pad); GST_PAD_PREROLL_WAIT (pad);
if (G_UNLIKELY (GST_PAD_IS_FLUSHING (pad))) GST_DEBUG_OBJECT (basesink, "done preroll");
goto flushing; GST_OBJECT_LOCK (pad);
GST_OBJECT_UNLOCK (pad); if (G_UNLIKELY (GST_PAD_IS_FLUSHING (pad)))
} goto flushing;
GST_OBJECT_UNLOCK (pad);
/* we can start rendering the data now */
no_preroll:
GST_DEBUG_OBJECT (basesink, "no preroll needed");
/* maybe it was another sink that blocked in preroll, need to check for
buffers to drain */
basesink->have_preroll = FALSE;
ret = gst_base_sink_preroll_queue_empty (basesink, pad);
GST_PAD_PREROLL_UNLOCK (pad); GST_PAD_PREROLL_UNLOCK (pad);
return GST_FLOW_OK; return ret;
no_preroll: /* special cases */
{
GST_DEBUG_OBJECT (basesink, "no preroll needed");
/* maybe it was another sink that blocked in preroll, need to check for
buffers to drain */
basesink->have_preroll = FALSE;
ret = gst_base_sink_preroll_queue_empty (basesink, pad);
GST_PAD_PREROLL_UNLOCK (pad);
return ret;
}
dropping: dropping:
{ {
GstBuffer *buf; GstBuffer *buf;
GST_DEBUG_OBJECT (basesink, "dropping buffer"); GST_DEBUG_OBJECT (basesink, "dropping buffer");
/* take the buffer off the queue again */
buf = GST_BUFFER (g_queue_pop_tail (basesink->preroll_queue)); buf = GST_BUFFER (g_queue_pop_tail (basesink->preroll_queue));
gst_buffer_unref (buf); gst_buffer_unref (buf);
@ -792,6 +792,12 @@ preroll_failed:
return ret; return ret;
} }
more_preroll:
{
GST_DEBUG_OBJECT (basesink, "need more preroll data");
GST_PAD_PREROLL_UNLOCK (pad);
return GST_FLOW_OK;
}
} }
static gboolean static gboolean