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; }