From 1f94299c498a5eca2ab438eba56cddeee6139557 Mon Sep 17 00:00:00 2001 From: Thibault Saunier Date: Tue, 26 May 2020 19:14:53 -0400 Subject: [PATCH] validate: Wait for state change to consider commit as done Part-of: --- ges/ges-validate.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/ges/ges-validate.c b/ges/ges-validate.c index 515ad4138c..42d8523cb1 100644 --- a/ges/ges-validate.c +++ b/ges/ges-validate.c @@ -452,11 +452,21 @@ GST_END_VALIDATE_ACTION; static void -_commit_done_cb (GstBus * bus, GstMessage * message, GstValidateAction * action) +_state_changed_cb (GstBus * bus, GstMessage * message, + GstValidateAction * action) { - gst_validate_action_set_done (action); + GstState next_state; - g_signal_handlers_disconnect_by_func (bus, _commit_done_cb, action); + if (!GST_IS_PIPELINE (GST_MESSAGE_SRC (message))) + return; + + gst_message_parse_state_changed (message, NULL, NULL, &next_state); + + if (next_state == GST_STATE_VOID_PENDING) { + gst_validate_action_set_done (action); + + g_signal_handlers_disconnect_by_func (bus, _state_changed_cb, action); + } } GES_START_VALIDATE_ACTION (_commit) @@ -469,12 +479,12 @@ GES_START_VALIDATE_ACTION (_commit) gst_validate_printf (action, "Committing timeline %s\n", GST_OBJECT_NAME (timeline)); - g_signal_connect (bus, "message::async-done", G_CALLBACK (_commit_done_cb), - action); + g_signal_connect (bus, "message::state-changed", + G_CALLBACK (_state_changed_cb), action); gst_element_get_state (pipeline, &state, NULL, 0); if (!ges_timeline_commit (timeline) || state < GST_STATE_PAUSED) { - g_signal_handlers_disconnect_by_func (bus, G_CALLBACK (_commit_done_cb), + g_signal_handlers_disconnect_by_func (bus, G_CALLBACK (_state_changed_cb), action); gst_object_unref (bus); goto done;