[ekiga/ds-gsettings3] VideoInputCore: Fixed possible deadlocks on exit.



commit c88b940cb4f656b9dc2dd78726de9f5aecd6c463
Author: Damien Sandras <dsandras beip be>
Date:   Sat Nov 23 11:56:18 2013 +0100

    VideoInputCore: Fixed possible deadlocks on exit.

 lib/engine/videoinput/videoinput-core.cpp |   20 ++++++++++++--------
 1 files changed, 12 insertions(+), 8 deletions(-)
---
diff --git a/lib/engine/videoinput/videoinput-core.cpp b/lib/engine/videoinput/videoinput-core.cpp
index 41a654f..e062f31 100644
--- a/lib/engine/videoinput/videoinput-core.cpp
+++ b/lib/engine/videoinput/videoinput-core.cpp
@@ -63,12 +63,16 @@ void VideoInputCore::VideoPreviewManager::quit ()
 {
   stop ();
 
-  PWaitAndSignal q(exit_mutex);
-  end_thread = true;
+  {
+    PWaitAndSignal q(exit_mutex);
+    end_thread = true;
+  }
 
-  PWaitAndSignal m(thread_mutex);
-  if (frame)
-    free (frame);
+  {
+    PWaitAndSignal m(thread_mutex);
+    if (frame)
+      free (frame);
+  }
 }
 
 void VideoInputCore::VideoPreviewManager::start (unsigned _width, unsigned _height)
@@ -116,7 +120,7 @@ void VideoInputCore::VideoPreviewManager::Main ()
         frame = (char*) malloc (unsigned (width * height * 3 / 2));
       }
     }
-    while (capture) {
+    while (capture && !exit) {
 
       if (frame) {
 
@@ -185,10 +189,10 @@ VideoInputCore::VideoInputCore (Ekiga::ServiceCore & _core,
 
 VideoInputCore::~VideoInputCore ()
 {
-  PWaitAndSignal m(core_mutex);
-
   preview_manager->quit ();
 
+  PWaitAndSignal m(core_mutex);
+
   for (std::set<VideoInputManager *>::iterator iter = managers.begin ();
        iter != managers.end ();
        iter++)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]