From 73646bd04f4755ae3709ae4bd10b122e74358711 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Wed, 23 Jul 2014 12:36:15 +0200 Subject: [PATCH] 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 --- gst/playback/gstplaybin2.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/gst/playback/gstplaybin2.c b/gst/playback/gstplaybin2.c index 23801292a9..75499a1c1e 100644 --- a/gst/playback/gstplaybin2.c +++ b/gst/playback/gstplaybin2.c @@ -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: