[ekiga/v4_0] Made sure the video preview manager thread is shut down correctly (and timely!)



commit fc49cda5050295cd709c2854e18f5ee4ffcc4122
Author: Julien Puydt <jpuydt free fr>
Date:   Thu Jan 17 22:18:14 2013 +0100

    Made sure the video preview manager thread is shut down correctly (and timely!)

 lib/engine/videoinput/videoinput-core.cpp |   22 +++++++++++++---------
 lib/engine/videoinput/videoinput-core.h   |    2 +-
 2 files changed, 14 insertions(+), 10 deletions(-)
---
diff --git a/lib/engine/videoinput/videoinput-core.cpp b/lib/engine/videoinput/videoinput-core.cpp
index d801839..b00d03b 100644
--- a/lib/engine/videoinput/videoinput-core.cpp
+++ b/lib/engine/videoinput/videoinput-core.cpp
@@ -125,11 +125,13 @@ void VideoInputCore::VideoPreviewManager::Main ()
 
 VideoInputCore::VideoInputCore (Ekiga::ServiceCore & _core,
                                 boost::shared_ptr<VideoOutputCore> _videooutput_core)
-: core(_core), preview_manager(*this, _videooutput_core)
+  : core(_core)
 {
   PWaitAndSignal m_var(core_mutex);
   PWaitAndSignal m_set(settings_mutex);
 
+  preview_manager = new VideoPreviewManager (*this, _videooutput_core);
+
   preview_config.active = false;
   preview_config.width = 176;
   preview_config.height = 144;
@@ -162,6 +164,8 @@ VideoInputCore::~VideoInputCore ()
   if (videoinput_core_conf_bridge)
     delete videoinput_core_conf_bridge;
 
+  delete preview_manager;
+
   for (std::set<VideoInputManager *>::iterator iter = managers.begin ();
        iter != managers.end ();
        iter++)
@@ -292,11 +296,11 @@ void VideoInputCore::set_preview_config (unsigned width, unsigned height, unsign
   if ( ( preview_config.active && !stream_config.active) &&
        ( preview_config        !=  new_preview_config) )
   {
-    preview_manager.stop();
+    preview_manager->stop();
     internal_close();
 
     internal_open(new_preview_config.width, new_preview_config.height, new_preview_config.fps);
-    preview_manager.start(new_preview_config.width, new_preview_config.height);
+    preview_manager->start(new_preview_config.width, new_preview_config.height);
   }
 
   preview_config = new_preview_config;
@@ -310,7 +314,7 @@ void VideoInputCore::start_preview ()
   PTRACE(4, "VidInputCore\tStarting preview " << preview_config);
   if (!preview_config.active && !stream_config.active) {
     internal_open(preview_config.width, preview_config.height, preview_config.fps);
-    preview_manager.start(preview_config.width, preview_config.height);
+    preview_manager->start(preview_config.width, preview_config.height);
   }
 
   preview_config.active = true;
@@ -322,7 +326,7 @@ void VideoInputCore::stop_preview ()
 
   PTRACE(4, "VidInputCore\tStopping Preview");
   if (preview_config.active && !stream_config.active) {
-    preview_manager.stop();
+    preview_manager->stop();
     internal_close();
     internal_set_manager(desired_device, current_channel, current_format);
   }
@@ -352,7 +356,7 @@ void VideoInputCore::start_stream ()
 
   PTRACE(4, "VidInputCore\tStarting stream " << stream_config);
   if (preview_config.active && !stream_config.active) {
-    preview_manager.stop();
+    preview_manager->stop();
     if ( preview_config != stream_config ) 
     {
       internal_close();
@@ -379,7 +383,7 @@ void VideoInputCore::stop_stream ()
       internal_set_manager(desired_device, current_channel, current_format);
       internal_open(preview_config.width, preview_config.height, preview_config.fps);
     }
-    preview_manager.start(preview_config.width, preview_config.height);
+    preview_manager->start(preview_config.width, preview_config.height);
   }
 
   if (!preview_config.active && stream_config.active) {
@@ -465,7 +469,7 @@ void VideoInputCore::internal_set_device(const VideoInputDevice & device, int ch
   PTRACE(4, "VidInputCore\tSetting device: " << device);
 
   if (preview_config.active && !stream_config.active)
-    preview_manager.stop();
+    preview_manager->stop();
 
   if (preview_config.active || stream_config.active)
     internal_close();
@@ -474,7 +478,7 @@ void VideoInputCore::internal_set_device(const VideoInputDevice & device, int ch
 
   if (preview_config.active && !stream_config.active) {
     internal_open(preview_config.width, preview_config.height, preview_config.fps);
-    preview_manager.start(preview_config.width,preview_config.height);
+    preview_manager->start(preview_config.width,preview_config.height);
   }
 
   if (stream_config.active)
diff --git a/lib/engine/videoinput/videoinput-core.h b/lib/engine/videoinput/videoinput-core.h
index 41f895d..967ee6a 100644
--- a/lib/engine/videoinput/videoinput-core.h
+++ b/lib/engine/videoinput/videoinput-core.h
@@ -438,7 +438,7 @@ private:
       PMutex settings_mutex;
 
       Ekiga::ServiceCore & core;
-      VideoPreviewManager preview_manager;
+      VideoPreviewManager* preview_manager;
       VideoInputCoreConfBridge* videoinput_core_conf_bridge;
       boost::shared_ptr<Ekiga::NotificationCore> notification_core;
     };


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