dc1394src: check for disabled transmission in _stop_cam
authorJoan Pau Beltran <joanpau.beltran@socib.cat>
Fri, 17 Jun 2016 12:31:42 +0000 (14:31 +0200)
committerTim-Philipp Müller <tim@centricular.com>
Mon, 20 Jun 2016 20:46:23 +0000 (21:46 +0100)
For symetry with _start_cam, check that the transmission
is effectively disabled in _stop_cam.

https://bugzilla.gnome.org/show_bug.cgi?id=763026

ext/dc1394/gstdc1394src.c

index c320ef2..3ab3026 100644 (file)
@@ -658,7 +658,15 @@ static gboolean
 gst_dc1394_src_stop_cam (GstDC1394Src * src)
 {
   dc1394error_t ret;
+  dc1394switch_t status;
+  guint trials;
 
+  /*
+   * TODO: dc1394_capture_setup/stop can start/stop the transmission
+   * when called with DC1394_CAPTURE_FLAGS_AUTO_ISO in the flags.
+   * The repeated trials check is a leftover of the original code,
+   * and might not be needed.
+   */
   GST_DEBUG_OBJECT (src, "Disable camera transmission.");
   ret = dc1394_video_set_transmission (src->camera, DC1394_OFF);
   if (ret != DC1394_SUCCESS) {
@@ -667,6 +675,20 @@ gst_dc1394_src_stop_cam (GstDC1394Src * src)
             dc1394_error_get_string (ret)));
     return FALSE;
   }
+  ret = dc1394_video_get_transmission (src->camera, &status);
+  for (trials = 10;
+      (trials > 0) && !(ret == DC1394_SUCCESS && status == DC1394_OFF);
+      trials--) {
+    GST_DEBUG_OBJECT (src,
+        "Wait for camera to stop transmission (%d trials left).", trials);
+    g_usleep (50000);
+    ret = dc1394_video_get_transmission (src->camera, &status);
+  }
+  if (!(ret == DC1394_SUCCESS && status == DC1394_OFF)) {
+    GST_WARNING_OBJECT (src,
+        "Could not get negative transmission status: %s.",
+        dc1394_error_get_string (ret));
+  }
 
   GST_DEBUG_OBJECT (src, "Clear capture resources.");
   ret = dc1394_capture_stop (src->camera);