Ignore camera errors while stopping the pipeline.
authorMohammed Sameer <msameer@foolab.org>
Sat, 20 Oct 2012 00:53:24 +0000 (03:53 +0300)
committerMohammed Sameer <msameer@foolab.org>
Sat, 20 Oct 2012 00:53:24 +0000 (03:53 +0300)
lib/qtcamdevice.cpp
lib/qtcamdevice_p.h

index 0009fff..cf088b6 100644 (file)
@@ -214,6 +214,8 @@ bool QtCamDevice::stop() {
 
   d_ptr->viewfinder->stop();
 
+  d_ptr->stopping = true;
+
   // First we go to ready:
   GstStateChangeReturn st = gst_element_set_state(d_ptr->cameraBin, GST_STATE_READY);
   if (st != GST_STATE_CHANGE_FAILURE) {
@@ -224,6 +226,8 @@ bool QtCamDevice::stop() {
   // Now to NULL
   gst_element_set_state(d_ptr->cameraBin, GST_STATE_NULL);
 
+  d_ptr->stopping = false;
+
   return true;
 }
 
index 45205c4..914928b 100644 (file)
@@ -47,7 +47,8 @@ public:
     viewfinder(0),
     conf(0),
     error(false),
-    notifications(0) {
+    notifications(0),
+    stopping(false) {
 
   }
 
@@ -131,6 +132,11 @@ public:
   }
 
   void _d_error(const QString& message, int code, const QString& debug) {
+    if (stopping) {
+      // TODO: is it wise to ignore errors while stopping??
+      return;
+    }
+
     error = true;
 
     QMetaObject::invokeMethod(q_ptr, "error", Q_ARG(QString, message),
@@ -235,6 +241,7 @@ public:
   QtCamGStreamerMessageListener *listener;
   bool error;
   QtCamNotifications *notifications;
+  bool stopping;
 };
 
 #endif /* QT_CAM_DEVICE_P_H */