From 5cb8164938cc4b902ee697a5754e203464fed9e1 Mon Sep 17 00:00:00 2001 From: Thiago Santos Date: Wed, 29 Sep 2010 17:34:00 -0300 Subject: [PATCH] camerabin: Do not wrongly fail when starting a capture If the elements are in NULL/READY and changing state to PAUSED/PLAYING while a capture is started camerabin might not set the active_bin properly causing the capture start to fail. This patch fixes it by checking the current and pending state of the branches instead of only the current one --- gst/camerabin/gstcamerabin.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/gst/camerabin/gstcamerabin.c b/gst/camerabin/gstcamerabin.c index 5f2ef6d..000b69d 100644 --- a/gst/camerabin/gstcamerabin.c +++ b/gst/camerabin/gstcamerabin.c @@ -963,15 +963,17 @@ static void gst_camerabin_change_mode (GstCameraBin * camera, gint mode) { if (camera->mode != mode || !camera->active_bin) { - GstState state; + GstState state, pending_state; GST_DEBUG_OBJECT (camera, "setting mode: %d (old_mode=%d)", mode, camera->mode); /* Interrupt ongoing capture */ gst_camerabin_do_stop (camera); camera->mode = mode; - gst_element_get_state (GST_ELEMENT (camera), &state, NULL, 0); - if (state == GST_STATE_PAUSED || state == GST_STATE_PLAYING) { + gst_element_get_state (GST_ELEMENT (camera), &state, &pending_state, 0); + if (state == GST_STATE_PAUSED || state == GST_STATE_PLAYING || + pending_state == GST_STATE_PAUSED + || pending_state == GST_STATE_PLAYING) { if (camera->active_bin) { GST_DEBUG_OBJECT (camera, "stopping active bin"); gst_element_set_state (camera->active_bin, GST_STATE_READY); -- 2.7.4