[ekiga] Made the opal video output code fetch engine services at startup



commit 4b12f105617bd9be1f4ffe547dce047d12ce5fa6
Author: Julien Puydt <jpuydt free fr>
Date:   Wed Jan 23 16:42:18 2013 +0100

    Made the opal video output code fetch engine services at startup

 lib/engine/components/opal/opal-plugins-hook.cpp |   14 +++++++++++---
 lib/engine/components/opal/opal-videooutput.cpp  |    6 ++----
 lib/engine/components/opal/opal-videooutput.h    |    3 +--
 3 files changed, 14 insertions(+), 9 deletions(-)
---
diff --git a/lib/engine/components/opal/opal-plugins-hook.cpp b/lib/engine/components/opal/opal-plugins-hook.cpp
index 4dbdd77..709495b 100644
--- a/lib/engine/components/opal/opal-plugins-hook.cpp
+++ b/lib/engine/components/opal/opal-plugins-hook.cpp
@@ -102,11 +102,19 @@ class PVideoOutputDevice_EKIGA_PluginServiceDescriptor : public PDevicePluginSer
 {
 public:
 
-  PVideoOutputDevice_EKIGA_PluginServiceDescriptor (Ekiga::ServiceCore& core_): core(core_)
+  PVideoOutputDevice_EKIGA_PluginServiceDescriptor (Ekiga::ServiceCore& core):
+    videooutput_core(core.get<Ekiga::VideoOutputCore> ("videooutput-core"))
   {}
 
   virtual PObject *CreateInstance (int) const
-  { return new PVideoOutputDevice_EKIGA (core); }
+  {
+    // FIXME: if it happens in a thread, that's bad...
+    boost::shared_ptr<Ekiga::VideoOutputCore> output = videooutput_core.lock ();
+    if (output)
+      return new PVideoOutputDevice_EKIGA (output);
+    else
+      return NULL;
+  }
 
   virtual PStringArray GetDeviceNames (int) const
   { return PStringList("EKIGA"); }
@@ -117,7 +125,7 @@ public:
 
 private:
 
-  Ekiga::ServiceCore& core;
+  boost::weak_ptr<Ekiga::VideoOutputCore> videooutput_core;
 };
 
 // now, let's rock :
diff --git a/lib/engine/components/opal/opal-videooutput.cpp b/lib/engine/components/opal/opal-videooutput.cpp
index 14ea264..a9669c2 100644
--- a/lib/engine/components/opal/opal-videooutput.cpp
+++ b/lib/engine/components/opal/opal-videooutput.cpp
@@ -46,8 +46,8 @@ int PVideoOutputDevice_EKIGA::devices_nbr = 0;
 PMutex PVideoOutputDevice_EKIGA::videoDisplay_mutex;
 
 /* The Methods */
-PVideoOutputDevice_EKIGA::PVideoOutputDevice_EKIGA (Ekiga::ServiceCore & _core)
-: core (_core)
+PVideoOutputDevice_EKIGA::PVideoOutputDevice_EKIGA (boost::shared_ptr<Ekiga::VideoOutputCore> _videooutput_core):
+  videooutput_core(_videooutput_core)
 {
   PWaitAndSignal m(videoDisplay_mutex); /* FIXME: if it's really needed
 					 * then we may crash : it's wrong to
@@ -55,8 +55,6 @@ PVideoOutputDevice_EKIGA::PVideoOutputDevice_EKIGA (Ekiga::ServiceCore & _core)
 					 * or not mutex.
 					 */
 
-  videooutput_core = core.get<Ekiga::VideoOutputCore> ("videooutput-core");
-
   is_active = FALSE;
 
   /* Used to distinguish between input and output device. */
diff --git a/lib/engine/components/opal/opal-videooutput.h b/lib/engine/components/opal/opal-videooutput.h
index 049eeba..38d786d 100644
--- a/lib/engine/components/opal/opal-videooutput.h
+++ b/lib/engine/components/opal/opal-videooutput.h
@@ -54,7 +54,7 @@ class PVideoOutputDevice_EKIGA : public PVideoOutputDevice
    * BEHAVIOR     :  /
    * PRE          :  /
    */
-  PVideoOutputDevice_EKIGA (Ekiga::ServiceCore & core);
+  PVideoOutputDevice_EKIGA (boost::shared_ptr<Ekiga::VideoOutputCore> _videooutput_core);
 
 
   /* DESCRIPTION  :  The destructor.
@@ -142,7 +142,6 @@ class PVideoOutputDevice_EKIGA : public PVideoOutputDevice
     REMOTE,
   };
 
-  Ekiga::ServiceCore & core;
   boost::shared_ptr<Ekiga::VideoOutputCore> videooutput_core;
 };
 



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