Expose logic to wait for preroll so that subclasses such as audiosink can also use this method.

Original commit message from CVS:
* docs/libs/gstreamer-libs-sections.txt:
* libs/gst/base/gstbasesink.c: (gst_base_sink_wait_preroll),
(gst_base_sink_do_sync):
* libs/gst/base/gstbasesink.h:
Expose logic to wait for preroll so that subclasses such as audiosink
can also use this method.
API: gst_base_sink_wait_preroll()
This commit is contained in:
Wim Taymans 2006-09-15 08:47:36 +00:00
parent bb634398b7
commit 6efdf610a3
4 changed files with 55 additions and 7 deletions

View file

@ -1,3 +1,13 @@
2006-09-15 Wim Taymans <wim@fluendo.com>
* docs/libs/gstreamer-libs-sections.txt:
* libs/gst/base/gstbasesink.c: (gst_base_sink_wait_preroll),
(gst_base_sink_do_sync):
* libs/gst/base/gstbasesink.h:
Expose logic to wait for preroll so that subclasses such as audiosink
can also use this method.
API: gst_base_sink_wait_preroll()
2006-09-15 Wim Taymans <wim@fluendo.com> 2006-09-15 Wim Taymans <wim@fluendo.com>
* gst/gstobject.c: (gst_object_set_parent): * gst/gstobject.c: (gst_object_set_parent):

View file

@ -167,7 +167,6 @@ GST_BASE_SRC_GET_CLASS
gst_base_src_get_type gst_base_src_get_type
</SECTION> </SECTION>
<SECTION> <SECTION>
<FILE>gstbasesink</FILE> <FILE>gstbasesink</FILE>
<TITLE>GstBaseSink</TITLE> <TITLE>GstBaseSink</TITLE>
@ -175,6 +174,7 @@ gst_base_src_get_type
GstBaseSink GstBaseSink
GstBaseSinkClass GstBaseSinkClass
gst_base_sink_wait_preroll
gst_base_sink_set_sync gst_base_sink_set_sync
gst_base_sink_get_sync gst_base_sink_get_sync
gst_base_sink_set_max_lateness gst_base_sink_set_max_lateness

View file

@ -1034,6 +1034,47 @@ no_clock:
} }
} }
/**
* gst_base_sink_wait_preroll:
* @sink: the sink
*
* If the #GstBaseSinkClass::render method performs its own synchronisation against
* the clock it must unblock when going from PLAYING to the PAUSED state and call
* this method before continuing to render the remaining data.
*
* This function will block until a state change to PLAYING happens (in which
* case this function returns #GST_FLOW_OK) or the processing must be stopped due
* to a state change to READY or a FLUSH event (in which case this function
* returns #GST_FLOW_WRONG_STATE).
*
* Since: 0.10.11
*
* Returns: #GST_FLOW_OK if the preroll completed and processing can
* continue. Any other return value should be returned from the render vmethod.
*/
GstFlowReturn
gst_base_sink_wait_preroll (GstBaseSink * sink)
{
/* block until the state changes, or we get a flush, or something */
GST_DEBUG_OBJECT (sink, "wait for preroll...");
sink->have_preroll = TRUE;
GST_PAD_PREROLL_WAIT (sink->sinkpad);
sink->have_preroll = FALSE;
GST_DEBUG_OBJECT (sink, "preroll done");
if (G_UNLIKELY (sink->flushing))
goto stopping;
GST_DEBUG_OBJECT (sink, "continue after preroll");
return GST_FLOW_OK;
/* ERRORS */
stopping:
{
GST_DEBUG_OBJECT (sink, "preroll interrupted");
return GST_FLOW_WRONG_STATE;
}
}
/* with STREAM_LOCK, PREROLL_LOCK /* with STREAM_LOCK, PREROLL_LOCK
* *
* Make sure we are in PLAYING and synchronize an object to the clock. * Make sure we are in PLAYING and synchronize an object to the clock.
@ -1112,12 +1153,7 @@ again:
* made us not need the preroll anymore */ * made us not need the preroll anymore */
if (G_LIKELY (basesink->need_preroll)) { if (G_LIKELY (basesink->need_preroll)) {
/* block until the state changes, or we get a flush, or something */ /* block until the state changes, or we get a flush, or something */
GST_DEBUG_OBJECT (basesink, "waiting to finish preroll"); if (gst_base_sink_wait_preroll (basesink) != GST_FLOW_OK)
basesink->have_preroll = TRUE;
GST_PAD_PREROLL_WAIT (pad);
basesink->have_preroll = FALSE;
GST_DEBUG_OBJECT (basesink, "done preroll");
if (G_UNLIKELY (basesink->flushing))
goto flushing; goto flushing;
} }
} }

View file

@ -166,6 +166,8 @@ struct _GstBaseSinkClass {
GType gst_base_sink_get_type(void); GType gst_base_sink_get_type(void);
GstFlowReturn gst_base_sink_wait_preroll (GstBaseSink *sink);
void gst_base_sink_set_sync (GstBaseSink *sink, gboolean sync); void gst_base_sink_set_sync (GstBaseSink *sink, gboolean sync);
gboolean gst_base_sink_get_sync (GstBaseSink *sink); gboolean gst_base_sink_get_sync (GstBaseSink *sink);