[ekiga/gnome-2-26] Fixed possible threading issues in PTLIB audio output code



commit feb886a85fb071d1044562bf5969c700c251e294
Author: Julien Puydt <jpuydt noether localdomain>
Date:   Tue Apr 21 17:01:13 2009 +0200

    Fixed possible threading issues in PTLIB audio output code
    
    don't use make_slot in threads
---
 .../components/ptlib/audiooutput-manager-ptlib.cpp |   31 +++++++++++++++++--
 .../components/ptlib/audiooutput-manager-ptlib.h   |   10 ++++++
 2 files changed, 37 insertions(+), 4 deletions(-)

diff --git a/lib/engine/components/ptlib/audiooutput-manager-ptlib.cpp b/lib/engine/components/ptlib/audiooutput-manager-ptlib.cpp
index 9d60dd3..763aaa4 100644
--- a/lib/engine/components/ptlib/audiooutput-manager-ptlib.cpp
+++ b/lib/engine/components/ptlib/audiooutput-manager-ptlib.cpp
@@ -129,7 +129,7 @@ bool GMAudioOutputManager_ptlib::open (Ekiga::AudioOutputPS ps, unsigned channel
 
   if (error_code != Ekiga::AO_ERROR_NONE) {
     PTRACE(1, "GMAudioOutputManager_ptlib\tEncountered error " << error_code << " while opening device[" << ps << "]");
-    Ekiga::Runtime::run_in_main (sigc::bind (device_error.make_slot (), ps, current_state[ps].device, error_code));
+    Ekiga::Runtime::run_in_main (sigc::bind (sigc::mem_fun (this, &GMAudioOutputManager_ptlib::device_error_in_main), ps, current_state[ps].device, error_code));
     return false;
   }
 
@@ -140,7 +140,7 @@ bool GMAudioOutputManager_ptlib::open (Ekiga::AudioOutputPS ps, unsigned channel
   Ekiga::AudioOutputSettings settings;
   settings.volume = volume;
   settings.modifyable = true;
-  Ekiga::Runtime::run_in_main (sigc::bind (device_opened.make_slot (), ps, current_state[ps].device, settings));
+  Ekiga::Runtime::run_in_main (sigc::bind (sigc::mem_fun (this, &GMAudioOutputManager_ptlib::device_opened_in_main), ps, current_state[ps].device, settings));
 
   return true;
 }
@@ -153,7 +153,7 @@ void GMAudioOutputManager_ptlib::close(Ekiga::AudioOutputPS ps)
      output_device[ps] = NULL;
   }
   current_state[ps].opened = false;
-  Ekiga::Runtime::run_in_main (sigc::bind (device_closed.make_slot (), ps, current_state[ps].device));
+  Ekiga::Runtime::run_in_main (sigc::bind (sigc::mem_fun (this, &GMAudioOutputManager_ptlib::device_closed_in_main), ps, current_state[ps].device));
 }
 
 void GMAudioOutputManager_ptlib::set_buffer_size (Ekiga::AudioOutputPS ps, unsigned buffer_size, unsigned num_buffers)
@@ -186,7 +186,7 @@ bool GMAudioOutputManager_ptlib::set_frame_data (Ekiga::AudioOutputPS ps,
     }
     if (bytes_written != size) {
       PTRACE(1, "GMAudioOutputManager_ptlib\tEncountered error while trying to write data");
-      Ekiga::Runtime::run_in_main (sigc::bind (device_error.make_slot (), ps, current_state[ps].device, Ekiga::AO_ERROR_WRITE));
+      Ekiga::Runtime::run_in_main (sigc::bind (sigc::mem_fun (this, &GMAudioOutputManager_ptlib::device_error_in_main), ps, current_state[ps].device, Ekiga::AO_ERROR_WRITE));
     }
   }
 
@@ -216,3 +216,26 @@ bool GMAudioOutputManager_ptlib::has_device(const std::string & sink, const std:
   }*/
   return false;
 }
+
+void
+GMAudioOutputManager_ptlib::device_opened_in_main (Ekiga::AudioOutputPS ps,
+						   Ekiga::AudioOutputDevice device,
+						   Ekiga::AudioOutputSettings settings)
+{
+  device_opened.emit (ps, device, settings);
+}
+
+void
+GMAudioOutputManager_ptlib::device_closed_in_main (Ekiga::AudioOutputPS ps,
+						   Ekiga::AudioOutputDevice device)
+{
+  device_closed.emit (ps, device);
+}
+
+void
+GMAudioOutputManager_ptlib::device_error_in_main (Ekiga::AudioOutputPS ps,
+						  Ekiga::AudioOutputDevice device,
+						  Ekiga::AudioOutputErrorCodes code)
+{
+  device_error.emit (ps, device, code);
+}
diff --git a/lib/engine/components/ptlib/audiooutput-manager-ptlib.h b/lib/engine/components/ptlib/audiooutput-manager-ptlib.h
index c473a7c..11fe918 100644
--- a/lib/engine/components/ptlib/audiooutput-manager-ptlib.h
+++ b/lib/engine/components/ptlib/audiooutput-manager-ptlib.h
@@ -81,6 +81,16 @@
       Ekiga::ServiceCore & core;
 
       PSoundChannel *output_device[2];
+
+    private:
+      void device_opened_in_main (Ekiga::AudioOutputPS ps,
+				  Ekiga::AudioOutputDevice device,
+				  Ekiga::AudioOutputSettings settings);
+      void device_closed_in_main (Ekiga::AudioOutputPS ps,
+				  Ekiga::AudioOutputDevice device);
+      void device_error_in_main (Ekiga::AudioOutputPS ps,
+				 Ekiga::AudioOutputDevice device,
+				 Ekiga::AudioOutputErrorCodes code);
   };
 
 /**



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