mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-20 08:41:07 +00:00
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
This commit is contained in:
parent
de97a994ba
commit
5cb8164938
1 changed files with 5 additions and 3 deletions
|
@ -963,15 +963,17 @@ static void
|
||||||
gst_camerabin_change_mode (GstCameraBin * camera, gint mode)
|
gst_camerabin_change_mode (GstCameraBin * camera, gint mode)
|
||||||
{
|
{
|
||||||
if (camera->mode != mode || !camera->active_bin) {
|
if (camera->mode != mode || !camera->active_bin) {
|
||||||
GstState state;
|
GstState state, pending_state;
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (camera, "setting mode: %d (old_mode=%d)",
|
GST_DEBUG_OBJECT (camera, "setting mode: %d (old_mode=%d)",
|
||||||
mode, camera->mode);
|
mode, camera->mode);
|
||||||
/* Interrupt ongoing capture */
|
/* Interrupt ongoing capture */
|
||||||
gst_camerabin_do_stop (camera);
|
gst_camerabin_do_stop (camera);
|
||||||
camera->mode = mode;
|
camera->mode = mode;
|
||||||
gst_element_get_state (GST_ELEMENT (camera), &state, NULL, 0);
|
gst_element_get_state (GST_ELEMENT (camera), &state, &pending_state, 0);
|
||||||
if (state == GST_STATE_PAUSED || state == GST_STATE_PLAYING) {
|
if (state == GST_STATE_PAUSED || state == GST_STATE_PLAYING ||
|
||||||
|
pending_state == GST_STATE_PAUSED
|
||||||
|
|| pending_state == GST_STATE_PLAYING) {
|
||||||
if (camera->active_bin) {
|
if (camera->active_bin) {
|
||||||
GST_DEBUG_OBJECT (camera, "stopping active bin");
|
GST_DEBUG_OBJECT (camera, "stopping active bin");
|
||||||
gst_element_set_state (camera->active_bin, GST_STATE_READY);
|
gst_element_set_state (camera->active_bin, GST_STATE_READY);
|
||||||
|
|
Loading…
Reference in a new issue