Wait for the state change to playing to complete before returning.
authorMohammed Sameer <msameer@foolab.org>
Sat, 8 Sep 2012 13:56:08 +0000 (16:56 +0300)
committerMohammed Sameer <msameer@foolab.org>
Sat, 8 Sep 2012 13:58:55 +0000 (16:58 +0300)
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

index 93139e3..1903ca5 100644 (file)
@@ -140,6 +140,26 @@ bool QtCamDevice::start() {
     return false;
   }
 
     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;
 }
 
   return true;
 }