camerabin: fix NULL -> READY state change failure handling.

In some error situations the NULL -> READY state change failed
and camerabin elements were not destroyed.
This commit is contained in:
Teemu Katajisto 2009-09-10 13:41:40 +03:00 committed by Stefan Kost
parent 58bf3be730
commit 341d91520a
2 changed files with 7 additions and 0 deletions

View file

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

View file

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