From 0f21f592608e453a13074596c5a9544a62dc39c0 Mon Sep 17 00:00:00 2001 From: Julien Moutte Date: Sun, 15 Feb 2004 19:05:59 +0000 Subject: [PATCH] gst/gstbin.c: Fix a big bug that was breaking pipelines like sinesrc ! { queue ! osssink } when an error was thrown b... Original commit message from CVS: 2004-02-15 Julien MOUTTE * gst/gstbin.c: (gst_bin_change_state), (gst_bin_iterate): Fix a big bug that was breaking pipelines like sinesrc ! { queue ! osssink } when an error was thrown by osssink. Basically a state change failure for an element in a different scheduling group was considered as successfull , which means that caps nego was going on and weird stuff happened. Like i wrote in the comment there, if someone want to revert that please drop me a mail explaining why because i really see no point in keeping that broken behaviour there. * gst/gstqueue.c: (gst_queue_get): Add a safety check as the queue CAN be empty, we then return NULL which will trigger a nice error when pulling from the pad. --- ChangeLog | 14 ++++++++++++++ gst/gstbin.c | 18 +++++++++--------- gst/gstqueue.c | 3 +++ plugins/elements/gstqueue.c | 3 +++ 4 files changed, 29 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index 459ada2b33..ab7fb40b8a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2004-02-15 Julien MOUTTE + + * gst/gstbin.c: (gst_bin_change_state), (gst_bin_iterate): Fix a big + bug that was breaking pipelines like sinesrc ! { queue ! osssink } when + an error was thrown by osssink. Basically a state change failure for + an element in a different scheduling group was considered as successfull + , which means that caps nego was going on and weird stuff happened. Like + i wrote in the comment there, if someone want to revert that please + drop me a mail explaining why because i really see no point in keeping + that broken behaviour there. + * gst/gstqueue.c: (gst_queue_get): Add a safety check as the queue CAN + be empty, we then return NULL which will trigger a nice error when + pulling from the pad. + 2004-02-13 David Schleef * libs/gst/control/dparam.c: (gst_dparam_class_init), diff --git a/gst/gstbin.c b/gst/gstbin.c index c2a2012384..0dd559d58c 100644 --- a/gst/gstbin.c +++ b/gst/gstbin.c @@ -723,14 +723,13 @@ gst_bin_change_state (GstElement * element) GST_ELEMENT_NAME (child), pending, gst_element_state_get_name (pending)); gst_element_set_state (child, old_child_state); - /* FIXME, this is legacy code, a failed state change of a child should - * return a failure in all cases */ - if (GST_ELEMENT_SCHED (child) == GST_ELEMENT_SCHED (element)) { - /* try to reset it to what is was */ - GST_STATE_PENDING (element) = old_state; - - return GST_STATE_FAILURE; - } + /* There was a check for elements being in the same scheduling group + here. Removed by dolphy . No matter the + scheduling group we should always return a failure. This change + seems to work on my machine and fixes tons of issues. If anyone + want to revert please tell me what it breaks first, Thanks. */ + GST_STATE_PENDING (element) = old_state; + return GST_STATE_FAILURE; break; case GST_STATE_ASYNC: GST_CAT_DEBUG (GST_CAT_STATES, "child '%s' is changing state asynchronously", @@ -738,6 +737,8 @@ gst_bin_change_state (GstElement * element) have_async = TRUE; break; case GST_STATE_SUCCESS: + GST_CAT_DEBUG (GST_CAT_STATES, "child '%s' changed state to %d(%s) successfully", + GST_ELEMENT_NAME (child), pending, gst_element_state_get_name (pending)); break; } } @@ -1134,4 +1135,3 @@ gst_bin_iterate (GstBin *bin) return running; } - diff --git a/gst/gstqueue.c b/gst/gstqueue.c index b9f5e1c625..239b1a88bf 100644 --- a/gst/gstqueue.c +++ b/gst/gstqueue.c @@ -719,6 +719,9 @@ restart: data = g_queue_pop_head (queue->queue); GST_CAT_LOG_OBJECT (GST_CAT_DATAFLOW, queue, "retrieved data %p from queue", data); + + if (data == NULL) + return NULL; if (GST_IS_BUFFER (data)) { /* Update statistics */ diff --git a/plugins/elements/gstqueue.c b/plugins/elements/gstqueue.c index b9f5e1c625..239b1a88bf 100644 --- a/plugins/elements/gstqueue.c +++ b/plugins/elements/gstqueue.c @@ -719,6 +719,9 @@ restart: data = g_queue_pop_head (queue->queue); GST_CAT_LOG_OBJECT (GST_CAT_DATAFLOW, queue, "retrieved data %p from queue", data); + + if (data == NULL) + return NULL; if (GST_IS_BUFFER (data)) { /* Update statistics */