Yann Leboulanger píše v So 26. 03. 2011 v 23:02 +0100:
> On 03/26/2011 01:59 PM, Tomas Herfert wrote:
> > Dear gajim developers,
> >
> > I have created patch of multimedia_helpers.py file which adds pulseaudio
> > support for voice calls.
> >
> > Could you please add it to your sources?
> >
> > It's just two new lines of code. So I hope it won't be a problem.
> >
> > Please find the patch attached.
> >
> > Thanks!
> > Tomas Herfert
> 
> First, thanks for your patch. 2 things:
>   - I prefer you use trac (trac.gajim.org) for patches and bugs. It 
> helps following things.

Will do next time. Or do you want me to add this patch to the trac also?

>   - If pulseaudio isn't installed, we get 2 messages in console when 
> running:
> element 'pulsesrc' not found
> element 'pulsesink' not found
> Maybe there is a way to detect they are usable before trying to use them?
> 

Please find new patch attached. There is condition which detects whether
they are usable. 
It contains the previous patch also.

Thanks!
Tomas

diff -r 394443510fae src/common/multimedia_helpers.py
--- a/src/common/multimedia_helpers.py	Sat Mar 26 22:37:08 2011 +0100
+++ b/src/common/multimedia_helpers.py	Sun Mar 27 11:27:29 2011 +0200
@@ -28,22 +28,23 @@
 
     def detect_element(self, name, text, pipe='%s'):
         try:
-            element = gst.element_factory_make(name, '%spresencetest' % name)
-            if isinstance(element, gst.interfaces.PropertyProbe):
-                element.set_state(gst.STATE_READY)
-                element.probe_property_name('device')
-                devices = element.probe_get_values_name('device')
-                if devices:
-                    self.devices[text % _(' Default device')] = pipe % name
-                    for device in devices:
-                        element.set_state(gst.STATE_NULL)
-                        element.set_property('device', device)
-                        element.set_state(gst.STATE_READY)
-                        device_name = element.get_property('device-name')
-                        self.devices[text % device_name] = pipe % '%s device=%s' % (name, device)
-                element.set_state(gst.STATE_NULL)
-            else:
-                self.devices[text] = pipe % name
+            if gst.element_factory_find(name):
+                element = gst.element_factory_make(name, '%spresencetest' % name)
+                if isinstance(element, gst.interfaces.PropertyProbe):
+                    element.set_state(gst.STATE_READY)
+                    element.probe_property_name('device')
+                    devices = element.probe_get_values_name('device')
+                    if devices:
+                        self.devices[text % _(' Default device')] = pipe % name
+                        for device in devices:
+                            element.set_state(gst.STATE_NULL)
+                            element.set_property('device', device)
+                            element.set_state(gst.STATE_READY)
+                            device_name = element.get_property('device-name')
+                            self.devices[text % device_name] = pipe % '%s device=%s' % (name, device)
+                    element.set_state(gst.STATE_NULL)
+                else:
+                    self.devices[text] = pipe % name
         except ImportError:
             pass
         except gst.ElementNotFoundError:
@@ -62,7 +63,9 @@
         # Alsa src
         self.detect_element('alsasrc', _('ALSA: %s'),
                 '%s ! volume name=gajim_vol')
-
+        # Pulseaudio src
+        self.detect_element('pulsesrc', _('Pulse: %s'),
+                '%s ! volume name=gajim_vol')
 
 class AudioOutputManager(DeviceManager):
     def detect(self):
@@ -74,6 +77,9 @@
         # Alsa sink
         self.detect_element('alsasink', _('ALSA: %s'),
                 '%s sync=false')
+        # Pulseaudio sink
+        self.detect_element('pulsesink', _('Pulse: %s'),
+                '%s sync=false')
 
 
 class VideoInputManager(DeviceManager):
_______________________________________________
Gajim-devel mailing list
Gajim-devel@gajim.org
http://lists.gajim.org/cgi-bin/listinfo/gajim-devel

Reply via email to