From: Mohammed Sameer Date: Sat, 8 Sep 2012 13:56:08 +0000 (+0300) Subject: Wait for the state change to playing to complete before returning. X-Git-Url: http://cgit.sxemacs.org/?p=harmattan%2Fcameraplus;a=commitdiff_plain;h=e212f959ca1902b0f1f0ff077d189bcdbd5a9060 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. --- 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; }