From cc27a7fe3a4b3df3e629b539271dd992ea3c577f Mon Sep 17 00:00:00 2001 From: Thiago Santos Date: Thu, 15 Sep 2011 17:35:44 -0300 Subject: [PATCH] camerabin2: Reset last state change result on state-locked elements An element stores the result for the last state change it did and GstBin's state change handler will use this last result for state locked elements to decide if its state change was successfull or not. In camerabin2, the filesinks have their state locked and when they fail switching states, this last failure will be used if the application tries to change camerabin2's state, causing any state change to fail. This patch makes camerabin2 reset this last change failure, avoiding that camerabin2 fails on its next state changes. --- gst/camerabin2/gstcamerabin2.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/gst/camerabin2/gstcamerabin2.c b/gst/camerabin2/gstcamerabin2.c index e554d5b24e..aac9cc3d19 100644 --- a/gst/camerabin2/gstcamerabin2.c +++ b/gst/camerabin2/gstcamerabin2.c @@ -485,7 +485,12 @@ gst_camera_bin_src_notify_readyforcapture (GObject * obj, GParamSpec * pspec, GST_DEBUG_OBJECT (camera, "Switching videobin location to %s", location); g_object_set (camera->videosink, "location", location, NULL); g_free (location); - gst_element_set_state (camera->videosink, GST_STATE_PLAYING); + if (gst_element_set_state (camera->videosink, GST_STATE_PLAYING) == + GST_STATE_CHANGE_FAILURE) { + /* Resets the latest state change return, that would be a failure + * and could cause problems in a camerabin2 state change */ + gst_element_set_state (camera->videosink, GST_STATE_NULL); + } gst_element_set_state (camera->video_encodebin, GST_STATE_PLAYING); gst_element_set_state (camera->videobin_capsfilter, GST_STATE_PLAYING); } @@ -1219,7 +1224,12 @@ gst_camera_bin_image_sink_event_probe (GstPad * pad, GstEvent * event, GST_DEBUG_OBJECT (camerabin, "Setting filename to imagesink: %s", filename); g_object_set (camerabin->imagesink, "location", filename, NULL); - gst_element_set_state (camerabin->imagesink, GST_STATE_PLAYING); + if (gst_element_set_state (camerabin->imagesink, GST_STATE_PLAYING) == + GST_STATE_CHANGE_FAILURE) { + /* Resets the latest state change return, that would be a failure + * and could cause problems in a camerabin2 state change */ + gst_element_set_state (camerabin->imagesink, GST_STATE_NULL); + } } } break;