From 341d91520a4a6ce50907d1f135697654add9764f Mon Sep 17 00:00:00 2001 From: Teemu Katajisto Date: Thu, 10 Sep 2009 13:41:40 +0300 Subject: [PATCH] camerabin: fix NULL -> READY state change failure handling. In some error situations the NULL -> READY state change failed and camerabin elements were not destroyed. --- gst/camerabin/camerabingeneral.c | 1 + gst/camerabin/gstcamerabin.c | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/gst/camerabin/camerabingeneral.c b/gst/camerabin/camerabingeneral.c index c54d178287..5b4df175fe 100644 --- a/gst/camerabin/camerabingeneral.c +++ b/gst/camerabin/camerabingeneral.c @@ -205,6 +205,7 @@ gst_camerabin_remove_elements_from_bin (GstBin * bin) case GST_ITERATOR_OK: elem = GST_ELEMENT (data); gst_bin_remove (bin, elem); + gst_element_set_state (GST_ELEMENT (elem), GST_STATE_NULL); /* Iterator increased the element refcount, so unref */ gst_object_unref (elem); break; diff --git a/gst/camerabin/gstcamerabin.c b/gst/camerabin/gstcamerabin.c index 010090f038..79a17167ee 100644 --- a/gst/camerabin/gstcamerabin.c +++ b/gst/camerabin/gstcamerabin.c @@ -3171,6 +3171,12 @@ gst_camerabin_change_state (GstElement * element, GstStateChange transition) case GST_STATE_CHANGE_READY_TO_NULL: camerabin_destroy_elements (camera); break; + /* In some error situation camerabin may end up being still in NULL + state so we must take care of destroying elements. */ + case GST_STATE_CHANGE_NULL_TO_READY: + if (ret == GST_STATE_CHANGE_FAILURE) + camerabin_destroy_elements (camera); + break; default: break; }