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



commit ef773ccd10f418721eb6fe0f5f6b3745d5c57473
Author: Julien Puydt <jpuydt free fr>
Date:   Wed Jan 23 16:49:39 2013 +0100

    Made the opal video input code fetch the engine services at startup

 lib/engine/components/opal/opal-plugins-hook.cpp |   14 +++++++++++---
 lib/engine/components/opal/opal-videoinput.cpp   |    5 ++---
 lib/engine/components/opal/opal-videoinput.h     |    3 +--
 3 files changed, 14 insertions(+), 8 deletions(-)
---
diff --git a/lib/engine/components/opal/opal-plugins-hook.cpp b/lib/engine/components/opal/opal-plugins-hook.cpp
index 709495b..3c4953a 100644
--- a/lib/engine/components/opal/opal-plugins-hook.cpp
+++ b/lib/engine/components/opal/opal-plugins-hook.cpp
@@ -79,11 +79,19 @@ class PVideoInputDevice_EKIGA_PluginServiceDescriptor : public PDevicePluginServ
 {
 public:
 
-  PVideoInputDevice_EKIGA_PluginServiceDescriptor (Ekiga::ServiceCore &core_): core(core_)
+  PVideoInputDevice_EKIGA_PluginServiceDescriptor (Ekiga::ServiceCore& core):
+    videoinput_core(core.get<Ekiga::VideoInputCore> ("videoinput-core"))
   {}
 
   virtual PObject* CreateInstance (int) const
-  { return new PVideoInputDevice_EKIGA (core); }
+  {
+    // FIXME: if it happens in a thread, that's bad...
+    boost::shared_ptr<Ekiga::VideoInputCore> output = videoinput_core.lock ();
+    if (output)
+      return new PVideoInputDevice_EKIGA (output);
+    else
+      return NULL;
+  }
 
 
   virtual PStringArray GetDeviceNames (int) const
@@ -95,7 +103,7 @@ public:
 
 private:
 
-  Ekiga::ServiceCore& core;
+  boost::weak_ptr<Ekiga::VideoInputCore> videoinput_core;
 };
 
 class PVideoOutputDevice_EKIGA_PluginServiceDescriptor : public PDevicePluginServiceDescriptor
diff --git a/lib/engine/components/opal/opal-videoinput.cpp b/lib/engine/components/opal/opal-videoinput.cpp
index ea81867..66e0e40 100644
--- a/lib/engine/components/opal/opal-videoinput.cpp
+++ b/lib/engine/components/opal/opal-videoinput.cpp
@@ -40,10 +40,9 @@
 
 int PVideoInputDevice_EKIGA::devices_nbr = 0;
 
-PVideoInputDevice_EKIGA::PVideoInputDevice_EKIGA (Ekiga::ServiceCore & _core):
-  core (_core)
+PVideoInputDevice_EKIGA::PVideoInputDevice_EKIGA (boost::shared_ptr<Ekiga::VideoInputCore> _videoinput_core):
+  videoinput_core(_videoinput_core)
 {
-  videoinput_core = core.get<Ekiga::VideoInputCore> ("videoinput-core");
   opened = false;
   is_active = false;
 }
diff --git a/lib/engine/components/opal/opal-videoinput.h b/lib/engine/components/opal/opal-videoinput.h
index 4d801c0..0d2e150 100644
--- a/lib/engine/components/opal/opal-videoinput.h
+++ b/lib/engine/components/opal/opal-videoinput.h
@@ -56,7 +56,7 @@ class PVideoInputDevice_EKIGA : public PVideoInputDevice
    * BEHAVIOR     :  Creates the Fake Input Device.
    * PRE          :  /
    */
-  PVideoInputDevice_EKIGA (Ekiga::ServiceCore & core);
+  PVideoInputDevice_EKIGA (boost::shared_ptr<Ekiga::VideoInputCore> _videoinput_core);
 
 
   /* DESCRIPTION  :  The destructor
@@ -183,7 +183,6 @@ class PVideoInputDevice_EKIGA : public PVideoInputDevice
   bool is_active;
   
 protected:
-  Ekiga::ServiceCore & core;
   boost::shared_ptr<Ekiga::VideoInputCore> videoinput_core;
 
   bool opened;



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