[vlc-devel] commit: phonon: Add specific support for PulseAudio. (Colin Guthrie )

git version control git at videolan.org
Thu Feb 4 13:50:24 CET 2010


phonon-vlc | branch: master | Colin Guthrie <cguthrie at mandriva.org> | Sat Jan 30 11:52:50 2010 +0000| [4e970d64a50e185ac50c9b78fc42f7531c3fbc83] | committer: Jean-Baptiste Kempf 

phonon: Add specific support for PulseAudio.

This uses the PulseSupport class from phonon to allow use to support
PulseAudio nicely (e.g. nice device listings etc.)
(cherry picked from commit bf1ef7158347153310cf4644a66da14f85db38c9)

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

> http://git.videolan.org/gitweb.cgi/phonon-vlc.git/?a=commit;h=4e970d64a50e185ac50c9b78fc42f7531c3fbc83
---

 vlc/audiooutput.cpp   |   13 +++++++++++++
 vlc/backend.cpp       |   11 +++++++++++
 vlc/devicemanager.cpp |   21 +++++++++++++++++++++
 3 files changed, 45 insertions(+), 0 deletions(-)

diff --git a/vlc/audiooutput.cpp b/vlc/audiooutput.cpp
index ab889ea..48eefba 100644
--- a/vlc/audiooutput.cpp
+++ b/vlc/audiooutput.cpp
@@ -28,6 +28,10 @@
 
 #include "vlcloader.h"
 
+#ifdef PHONON_PULSESUPPORT
+#  include <phonon/pulsesupport.h>
+#endif
+
 namespace Phonon
 {
 namespace VLC {
@@ -70,6 +74,15 @@ bool AudioOutput::setOutputDevice(int device)
     if (i_device == device)
         return true;
 
+#ifdef PHONON_PULSESUPPORT
+    if (PulseSupport::getInstance()->isActive()) {
+        i_device = device;
+        libvlc_audio_output_set(vlc_instance, "pulse");
+        qDebug() << "set aout " << "pulse";
+        return true;
+    }
+#endif
+
     const QList<AudioDevice> deviceList = p_backend->deviceManager()->audioOutputDevices();
     if (device >= 0 && device < deviceList.size()) {
 
diff --git a/vlc/backend.cpp b/vlc/backend.cpp
index 0463722..7d2e010 100644
--- a/vlc/backend.cpp
+++ b/vlc/backend.cpp
@@ -31,6 +31,10 @@
 #include "vlcloader.h"
 #include "vlcmediaobject.h"
 
+#ifdef PHONON_PULSESUPPORT
+#  include <phonon/pulsesupport.h>
+#endif
+
 #include <QtCore/QSet>
 #include <QtCore/QVariant>
 #include <QtCore/QtPlugin>
@@ -47,6 +51,13 @@ Backend::Backend(QObject *parent, const QVariantList &)
         , m_effectManager(NULL)
         , m_debugLevel(Debug)
 {
+#ifdef PHONON_PULSESUPPORT
+    // Initialise PulseAudio support
+    PulseSupport *pulse = PulseSupport::getInstance();
+    pulse->enable();
+    connect(pulse, SIGNAL(objectDescriptionChanged(ObjectDescriptionType)), SIGNAL(objectDescriptionChanged(ObjectDescriptionType)));
+#endif
+
     bool wasInit = vlcInit();
 
     setProperty("identifier",     QLatin1String("phonon_vlc"));
diff --git a/vlc/devicemanager.cpp b/vlc/devicemanager.cpp
index 3bea98c..18db2f7 100644
--- a/vlc/devicemanager.cpp
+++ b/vlc/devicemanager.cpp
@@ -21,6 +21,10 @@
 //#include "widgetrenderer.h"
 #include "vlcloader.h"
 
+#ifdef PHONON_PULSESUPPORT
+#  include <phonon/pulsesupport.h>
+#endif
+
 /**
  * This class manages the list of currently active output devices.
  */
@@ -102,13 +106,30 @@ void DeviceManager::updateDeviceList()
     vlcExceptionRaised();
     libvlc_audio_output_t *p_start = p_ao_list;
 
+    bool checkpulse = false;
+#ifdef PHONON_PULSESUPPORT
+    PulseSupport *pulse = PulseSupport::getInstance();
+    checkpulse = pulse->isActive();
+#endif
+    bool haspulse = false;
     while (p_ao_list) {
+        if (checkpulse && 0 == strcmp(p_ao_list->psz_name, "pulse")) {
+            haspulse = true;
+            break;
+        }
         list.append(p_ao_list->psz_name);
         list_hw.append("");
         p_ao_list = p_ao_list->p_next;
     }
     libvlc_audio_output_list_release(p_start);
 
+
+#ifdef PHONON_PULSESUPPORT
+    if (haspulse)
+        return;
+    pulse->enable(false);
+#endif
+
     for (int i = 0 ; i < list.size() ; ++i) {
         QByteArray nameId = list.at(i);
         QByteArray hwId = list_hw.at(i);




More information about the vlc-devel mailing list