playbin: Go asynchronously from READY to PAUSED

We now add all our elements to uridecodebin *after*
GstBin::change_state(READY->PAUSED), so we need to post async-start
and async-done messages ourselves if we want to work async.

https://bugzilla.gnome.org/show_bug.cgi?id=733495
This commit is contained in:
Sebastian Dröge 2014-07-23 12:36:15 +02:00
parent 5c038192e2
commit 73646bd04f

View file

@ -431,6 +431,7 @@ struct _GstPlayBin
GMutex dyn_lock;
/* if we are shutting down or not */
gint shutdown;
gboolean async_pending; /* async-start has been emitted */
GMutex elements_lock;
guint32 elements_cookie;
@ -1269,6 +1270,35 @@ gst_play_bin_class_init (GstPlayBinClass * klass)
GST_DEBUG_FUNCPTR (gst_play_bin_handle_message);
}
static void
do_async_start (GstPlayBin * playbin)
{
GstMessage *message;
playbin->async_pending = TRUE;
message = gst_message_new_async_start (GST_OBJECT_CAST (playbin));
GST_BIN_CLASS (parent_class)->handle_message (GST_BIN_CAST (playbin),
message);
}
static void
do_async_done (GstPlayBin * playbin)
{
GstMessage *message;
if (playbin->async_pending) {
GST_DEBUG_OBJECT (playbin, "posting ASYNC_DONE");
message =
gst_message_new_async_done (GST_OBJECT_CAST (playbin),
GST_CLOCK_TIME_NONE);
GST_BIN_CLASS (parent_class)->handle_message (GST_BIN_CAST (playbin),
message);
playbin->async_pending = FALSE;
}
}
static void
init_group (GstPlayBin * playbin, GstSourceGroup * group)
{
@ -3510,6 +3540,10 @@ no_more_pads_cb (GstElement * decodebin, GstSourceGroup * group)
GST_PLAY_BIN_SHUTDOWN_UNLOCK (playbin);
if (configure) {
do_async_done (playbin);
}
return;
shutdown:
@ -5442,6 +5476,7 @@ gst_play_bin_change_state (GstElement * element, GstStateChange transition)
GST_LOG_OBJECT (playbin, "clearing shutdown flag");
memset (&playbin->duration, 0, sizeof (playbin->duration));
g_atomic_int_set (&playbin->shutdown, 0);
do_async_start (playbin);
break;
case GST_STATE_CHANGE_PAUSED_TO_READY:
async_down:
@ -5485,8 +5520,10 @@ gst_play_bin_change_state (GstElement * element, GstStateChange transition)
ret = GST_STATE_CHANGE_FAILURE;
goto failure;
}
ret = GST_STATE_CHANGE_ASYNC;
break;
case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
do_async_done (playbin);
/* FIXME Release audio device when we implement that */
break;
case GST_STATE_CHANGE_PAUSED_TO_READY: