diff --git a/ChangeLog b/ChangeLog index 7c4571f4de..3b9d389a40 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2006-09-15 Wim Taymans + + * 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 * gst/gstobject.c: (gst_object_set_parent): diff --git a/docs/libs/gstreamer-libs-sections.txt b/docs/libs/gstreamer-libs-sections.txt index 30720f863b..08e1162aaa 100644 --- a/docs/libs/gstreamer-libs-sections.txt +++ b/docs/libs/gstreamer-libs-sections.txt @@ -167,7 +167,6 @@ GST_BASE_SRC_GET_CLASS gst_base_src_get_type -
gstbasesink GstBaseSink @@ -175,6 +174,7 @@ gst_base_src_get_type GstBaseSink GstBaseSinkClass +gst_base_sink_wait_preroll gst_base_sink_set_sync gst_base_sink_get_sync gst_base_sink_set_max_lateness diff --git a/libs/gst/base/gstbasesink.c b/libs/gst/base/gstbasesink.c index 3d29dc86cd..01fdf4a45d 100644 --- a/libs/gst/base/gstbasesink.c +++ b/libs/gst/base/gstbasesink.c @@ -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 * * 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 */ if (G_LIKELY (basesink->need_preroll)) { /* block until the state changes, or we get a flush, or something */ - GST_DEBUG_OBJECT (basesink, "waiting to finish preroll"); - basesink->have_preroll = TRUE; - GST_PAD_PREROLL_WAIT (pad); - basesink->have_preroll = FALSE; - GST_DEBUG_OBJECT (basesink, "done preroll"); - if (G_UNLIKELY (basesink->flushing)) + if (gst_base_sink_wait_preroll (basesink) != GST_FLOW_OK) goto flushing; } } diff --git a/libs/gst/base/gstbasesink.h b/libs/gst/base/gstbasesink.h index 0f17bd07e4..e6c406897d 100644 --- a/libs/gst/base/gstbasesink.h +++ b/libs/gst/base/gstbasesink.h @@ -166,6 +166,8 @@ struct _GstBaseSinkClass { 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); gboolean gst_base_sink_get_sync (GstBaseSink *sink);