[ekiga] VideoInputCore: Ensure proper termination of Preview thread.



commit 9b8e976024ddcc26a7796aeba6ec8cf09cc75ac8
Author: Damien Sandras <dsandras seconix com>
Date:   Sun Feb 8 16:53:09 2015 +0100

    VideoInputCore: Ensure proper termination of Preview thread.

 lib/engine/videoinput/videoinput-core.cpp |   22 +++++++++++++++++++---
 lib/engine/videoinput/videoinput-core.h   |    3 +++
 2 files changed, 22 insertions(+), 3 deletions(-)
---
diff --git a/lib/engine/videoinput/videoinput-core.cpp b/lib/engine/videoinput/videoinput-core.cpp
index 52c2d54..57a81ed 100644
--- a/lib/engine/videoinput/videoinput-core.cpp
+++ b/lib/engine/videoinput/videoinput-core.cpp
@@ -37,6 +37,8 @@
 
 #include <glib/gi18n.h>
 
+#include "config.h"
+
 #include "videoinput-core.h"
 #include "videooutput-manager.h"
 #include "videoinput-manager.h"
@@ -45,7 +47,7 @@ using namespace Ekiga;
 
 
 VideoInputCore::VideoPreviewManager::VideoPreviewManager (VideoInputCore& _videoinput_core, 
boost::shared_ptr<VideoOutputCore> _videooutput_core)
-: PThread (1000, AutoDeleteThread, HighestPriority, "VideoPreviewManager"),
+: PThread (1000, NoAutoDeleteThread, HighestPriority, "VideoPreviewManager"),
     videoinput_core (_videoinput_core),
   videooutput_core (_videooutput_core)
 {
@@ -59,6 +61,11 @@ VideoInputCore::VideoPreviewManager::VideoPreviewManager (VideoInputCore& _video
   this->Resume ();
 }
 
+VideoInputCore::VideoPreviewManager::~VideoPreviewManager ()
+{
+  quit ();
+}
+
 void VideoInputCore::VideoPreviewManager::quit ()
 {
   {
@@ -139,6 +146,12 @@ void VideoInputCore::VideoPreviewManager::Main ()
   }
 }
 
+void VideoInputCore::VideoPreviewManager::Terminate ()
+{
+  quit ();
+}
+
+
 VideoInputCore::VideoInputCore (Ekiga::ServiceCore & _core,
                                 boost::shared_ptr<VideoOutputCore> _videooutput_core)
   : core(_core)
@@ -148,7 +161,6 @@ VideoInputCore::VideoInputCore (Ekiga::ServiceCore & _core,
 
   preview_manager = new VideoPreviewManager (*this, _videooutput_core);
 
-
   preview_config.active = false;
   preview_config.width = 176;
   preview_config.height = 144;
@@ -181,7 +193,7 @@ VideoInputCore::VideoInputCore (Ekiga::ServiceCore & _core,
 
 VideoInputCore::~VideoInputCore ()
 {
-  preview_manager->quit ();
+  delete preview_manager;
 
   PWaitAndSignal m(core_mutex);
 
@@ -194,6 +206,10 @@ VideoInputCore::~VideoInputCore ()
 
   delete device_settings;
   delete video_codecs_settings;
+
+#if DEBUG
+  std::cout << "Ekiga::VideoInputCore: Destructor invoked" << std::endl << std::flush;
+#endif
 }
 
 
diff --git a/lib/engine/videoinput/videoinput-core.h b/lib/engine/videoinput/videoinput-core.h
index 2db1211..18a4cbc 100644
--- a/lib/engine/videoinput/videoinput-core.h
+++ b/lib/engine/videoinput/videoinput-core.h
@@ -332,6 +332,8 @@ private:
         */
         VideoPreviewManager(VideoInputCore & _videoinput_core, boost::shared_ptr<VideoOutputCore> 
_videooutput_core);
 
+        ~VideoPreviewManager ();
+
         void quit();
 
         /** Start the preview thread.
@@ -350,6 +352,7 @@ private:
 
       protected:
         void Main ();
+        void Terminate ();
         char* frame;
 
         bool end_thread;


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