From e212f959ca1902b0f1f0ff077d189bcdbd5a9060 Mon Sep 17 00:00:00 2001 From: Mohammed Sameer Date: Sat, 8 Sep 2012 16:56:08 +0300 Subject: [PATCH] Wait for the state change to playing to complete before returning. There seems to be a race condition: when we change the resolution while the pipeline is still undergoing its state change then subdevsrc2 will barf. This is visible when we startup in night mode. --- lib/qtcamdevice.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/lib/qtcamdevice.cpp b/lib/qtcamdevice.cpp index 93139e3..1903ca5 100644 --- a/lib/qtcamdevice.cpp +++ b/lib/qtcamdevice.cpp @@ -140,6 +140,26 @@ bool QtCamDevice::start() { return false; } + // We need to wait for startup to complet. There's a race condition somewhere in the pipeline. + // If we set the scene mode to night and update the resolution while starting up + // then subdevsrc2 barfs: + // streaming task paused, reason not-negotiated (-4) + GstState state; + if (err != GST_STATE_CHANGE_ASYNC) { + return true; + } + + if (gst_element_get_state(d_ptr->cameraBin, &state, 0, GST_CLOCK_TIME_NONE) + != GST_STATE_CHANGE_SUCCESS) { + // We are seriously screwed up :( + return false; + } + + if (state != GST_STATE_PLAYING) { + // Huh ? Is this even possible ?? + return false; + } + return true; } -- 2.25.1