gst-launch: go back down to GST_STATE_NULL in one step.

Going through each state on the way back down to GST_STATE_NULL
can cause deadlocks, for example:

gst-launch-1.0 audiotestsrc ! valve drop=true ! autoaudiosink

ctrl + C

Hangs forever when going to PAUSED, because the "final" state is
ASYNC, and the sink blocks waiting for a preroll buffer.

Going straight to NULL addresses this issue, and also helps
making teardown faster when piping sparse streams to a
sync sink.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/519>
This commit is contained in:
Mathieu Duponchelle 2020-04-01 15:41:49 +02:00 committed by GStreamer Merge Bot
parent cc13705855
commit 90e9bf1457

View file

@ -1089,7 +1089,6 @@ main (int argc, char *argv[])
}
if (!savefile) {
GstState state, pending;
GstStateChangeReturn ret;
GstBus *bus;
@ -1150,7 +1149,6 @@ main (int argc, char *argv[])
res = caught_error;
goto end;
}
state = GST_STATE_PAUSED;
/* fallthrough */
case GST_STATE_CHANGE_SUCCESS:
PRINT (_("Pipeline is PREROLLED ...\n"));
@ -1230,22 +1228,10 @@ main (int argc, char *argv[])
GST_TIME_ARGS (diff));
}
PRINT (_("Setting pipeline to PAUSED ...\n"));
gst_element_set_state (pipeline, GST_STATE_PAUSED);
if (caught_error == ELR_NO_ERROR)
gst_element_get_state (pipeline, &state, &pending, GST_CLOCK_TIME_NONE);
/* iterate mainloop to process pending stuff */
while (g_main_context_iteration (NULL, FALSE));
/* No need to see all those pad caps going to NULL etc., it's just noise */
if (deep_notify_id != 0)
g_signal_handler_disconnect (pipeline, deep_notify_id);
PRINT (_("Setting pipeline to READY ...\n"));
gst_element_set_state (pipeline, GST_STATE_READY);
gst_element_get_state (pipeline, &state, &pending, GST_CLOCK_TIME_NONE);
#if 0
if (check_index) {
print_index_stats (index_stats);