[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [phonon-vlc/five] src: Adapt to the removal of device access lists from Phonon
From:       Casian Andrei <skeletk13 () gmail ! com>
Date:       2013-11-15 13:23:11
Message-ID: E1VhJMd-00038N-0T () scm ! kde ! org
[Download RAW message or body]

Git commit 172147a1c2e0594467b6b2ba29f0d13402b01531 by Casian Andrei.
Committed on 15/11/2013 at 12:27.
Pushed by casianandrei into branch 'five'.

Adapt to the removal of device access lists from Phonon

M  +0    -26   src/audio/audiooutput.cpp
M  +42   -28   src/devicemanager.cpp
M  +17   -3    src/devicemanager.h
M  +1    -0    src/utils/vstring.h

http://commits.kde.org/phonon-vlc/172147a1c2e0594467b6b2ba29f0d13402b01531

diff --git a/src/audio/audiooutput.cpp b/src/audio/audiooutput.cpp
index baa5c9f..63bd11e 100644
--- a/src/audio/audiooutput.cpp
+++ b/src/audio/audiooutput.cpp
@@ -114,32 +114,6 @@ void AudioOutput::setOutputDeviceImplementation()
 #warning forcing pulse ... because I can.
     m_vlcPlayer->setAudioOutput("pulse");
     return;
-
-
-    const QVariant dalProperty = m_device.property("deviceAccessList");
-    if (!dalProperty.isValid()) {
-        error() << "Device" << m_device.property("name") << "has no access list";
-        return;
-    }
-    const DeviceAccessList deviceAccessList = dalProperty.value<DeviceAccessList>();
-    if (deviceAccessList.isEmpty()) {
-        error() << "Device" << m_device.property("name") << "has an empty access \
                list";
-        return;
-    }
-
-    // ### we're not trying the whole access list (could mean same device on \
                different soundsystems)
-    const DeviceAccess &firstDeviceAccess = deviceAccessList.first();
-
-    QByteArray soundSystem = firstDeviceAccess.first;
-    debug() << "Setting output soundsystem to" << soundSystem;
-    m_vlcPlayer->setAudioOutput(soundSystem);
-
-    QByteArray deviceName = firstDeviceAccess.second.toLatin1();
-    if (!deviceName.isEmpty()) {
-        // print the name as possibly messed up by toLatin1() to see conversion \
                problems
-        debug() << "Setting output device to" << deviceName << '(' << \
                m_device.name() << ')';
-        m_vlcPlayer->setAudioOutputDevice(soundSystem, deviceName);
-    }
 }
 
 void AudioOutput::applyVolume()
diff --git a/src/devicemanager.cpp b/src/devicemanager.cpp
index 75c1f59..aa5a5b4 100644
--- a/src/devicemanager.cpp
+++ b/src/devicemanager.cpp
@@ -78,16 +78,20 @@ void DeviceInfo::setAdvanced(bool advanced)
     m_isAdvanced = advanced;
 }
 
-const DeviceAccessList& DeviceInfo::accessList() const
+DeviceInfo::SoundSystem DeviceInfo::soundSystem() const
 {
-    return m_accessList;
+    return m_soundSystem;
 }
 
-void DeviceInfo::addAccess(const DeviceAccess& access)
+QByteArray DeviceInfo::deviceName() const
 {
-    if (m_accessList.isEmpty())
-        m_description = access.first + ": " + access.second;
-    m_accessList.append(access);
+    return m_deviceName;
+}
+
+void DeviceInfo::setAccessInfo(SoundSystem soundSystem, const QByteArray \
&deviceName) +{
+    m_soundSystem = soundSystem;
+    m_deviceName = deviceName;
 }
 
 quint16 DeviceInfo::capabilities() const
@@ -111,6 +115,15 @@ DeviceManager::DeviceManager(Backend *parent)
 {
     DEBUG_BLOCK;
     Q_ASSERT(parent);
+
+    m_knownSoundSystems.insert(DeviceInfo::Pulse, QByteArray("pulse"));
+    m_knownSoundSystems.insert(DeviceInfo::Alsa, QByteArray("alsa"));
+    m_knownSoundSystems.insert(DeviceInfo::Oss, QByteArray("oss"));
+    m_knownSoundSystems.insert(DeviceInfo::Jack, QByteArray("jack"));
+    m_knownSoundSystems.insert(DeviceInfo::Aout_DirectX, \
QByteArray("aout_directx")); +    m_knownSoundSystems.insert(DeviceInfo::DirectSound, \
QByteArray("directsound")); +    m_knownSoundSystems.insert(DeviceInfo::Auhal, \
QByteArray("auhal")); +
     updateDeviceList();
 }
 
@@ -152,7 +165,6 @@ QHash<QByteArray, QVariant> DeviceManager::deviceProperties(int \
id)  properties.insert("name", device.name());
             properties.insert("description", device.description());
             properties.insert("isAdvanced", device.isAdvanced());
-            properties.insert("deviceAccessList", \
QVariant::fromValue<Phonon::DeviceAccessList>(device.accessList()));  \
properties.insert("discovererIcon", "vlc");  
             if (device.capabilities() & DeviceInfo::AudioOutput) {
@@ -227,53 +239,45 @@ void DeviceManager::updateDeviceList()
     if (audioOutBackends.contains("pulse")) {
         DeviceInfo defaultAudioOutputDevice(tr("Default"), false);
         defaultAudioOutputDevice.setCapabilities(DeviceInfo::AudioOutput);
-        defaultAudioOutputDevice.addAccess(DeviceAccess("pulse", "default"));
+        defaultAudioOutputDevice.setAccessInfo(DeviceInfo::Pulse, "default");
         newDeviceList.append(defaultAudioOutputDevice);
         return;
     }
 
-    QList<QByteArray> knownSoundSystems;
-    // Whitelist - Order has no particular impact.
     // NOTE: if listing was not intercepted by the PA code above we also need
     //       to try injecting the pulse aout as otherwise the user would have to
     //       use the fake PA device in ALSA to output through PA (kind of silly).
-    knownSoundSystems << QByteArray("pulse")
-                      << QByteArray("alsa")
-                      << QByteArray("oss")
-                      << QByteArray("jack")
-                      << QByteArray("aout_directx") // Windows up to VLC 2.0
-                      << QByteArray("directsound") // Windows from VLC 2.1 upwards
-                      << QByteArray("auhal"); // Mac
-    foreach (const QByteArray &soundSystem, knownSoundSystems) {
-        if (!audioOutBackends.contains(soundSystem)) {
-            debug() << "Sound system" << soundSystem << "not supported by libvlc";
+
+    foreach (const QByteArray &soundSystemName, m_knownSoundSystems.values()) {
+        if (!audioOutBackends.contains(soundSystemName)) {
+            debug() << "Sound system" << soundSystemName << "not supported by \
libvlc";  continue;
         }
 
-        const int deviceCount = libvlc_audio_output_device_count(libvlc, \
soundSystem); +        const int deviceCount = \
libvlc_audio_output_device_count(libvlc, soundSystemName);  
         for (int i = 0; i < deviceCount; i++) {
-            VString idName(libvlc_audio_output_device_id(libvlc, soundSystem, i));
-            VString longName(libvlc_audio_output_device_longname(libvlc, \
soundSystem, i)); +            VString idName(libvlc_audio_output_device_id(libvlc, \
soundSystemName, i)); +            VString \
longName(libvlc_audio_output_device_longname(libvlc, soundSystemName, i));  
-            debug() << "found device" << soundSystem << idName << longName;
+            debug() << "found device" << soundSystemName << idName << longName;
 
             DeviceInfo device(longName, true);
-            device.addAccess(DeviceAccess(soundSystem, idName));
+            device.setAccessInfo(soundSystemFromName(soundSystemName), \
idName.const_data());  device.setCapabilities(DeviceInfo::AudioOutput);
             newDeviceList.append(device);
         }
 
         // libVLC gives no devices for some sound systems, like OSS
         if (deviceCount == 0) {
-            debug() << "manually injecting sound system" << soundSystem;
+            debug() << "manually injecting sound system" << soundSystemName;
             // NOTE: Do not mark manually injected devices as advanced.
             //       libphonon filters advanced devices from the default
             //       selection which on systems such as OSX or Windows can
             //       lead to an empty device list as the injected device is
             //       the only available one.
-            DeviceInfo device(QString::fromUtf8(soundSystem), false);
-            device.addAccess(DeviceAccess(soundSystem, ""));
+            DeviceInfo device(QString::fromUtf8(soundSystemName), false);
+            device.setAccessInfo(soundSystemFromName(soundSystemName), "");
             device.setCapabilities(DeviceInfo::AudioOutput);
             newDeviceList.append(device);
         }
@@ -316,5 +320,15 @@ bool DeviceManager::listContainsDevice(const QList<DeviceInfo> \
&list, int id)  return false;
 }
 
+DeviceInfo::SoundSystem DeviceManager::soundSystemFromName(const QByteArray &name)
+{
+    foreach (DeviceInfo::SoundSystem soundSystem, m_knownSoundSystems.keys()) {
+        if (m_knownSoundSystems.value(soundSystem) == name)
+            return soundSystem;
+    }
+
+    return DeviceInfo::UnknownSoundSystem;
+}
+
 }
 }
diff --git a/src/devicemanager.h b/src/devicemanager.h
index b755ba1..6575f6d 100644
--- a/src/devicemanager.h
+++ b/src/devicemanager.h
@@ -44,6 +44,16 @@ public:
         AudioCapture    = 0x0002,
         VideoCapture    = 0x0004
     };
+    enum SoundSystem {
+        UnknownSoundSystem = 0,
+        Pulse,
+        Alsa,
+        Oss,
+        Jack,
+        Aout_DirectX,
+        DirectSound,
+        Auhal
+    };
 public:
     /**
      * Constructs a device info object and sets it's device identifiers.
@@ -55,8 +65,9 @@ public:
     const QString& description() const;
     bool isAdvanced() const;
     void setAdvanced(bool advanced);
-    const DeviceAccessList& accessList() const;
-    void addAccess(const DeviceAccess &access);
+    SoundSystem soundSystem() const;
+    QByteArray deviceName() const;
+    void setAccessInfo(SoundSystem soundSystem, const QByteArray &deviceName);
     quint16 capabilities() const;
     void setCapabilities(quint16 cap);
 
@@ -65,7 +76,8 @@ private:
     QString m_name;
     QString m_description;
     bool m_isAdvanced;
-    DeviceAccessList m_accessList;
+    SoundSystem m_soundSystem;
+    QByteArray m_deviceName;
     quint16 m_capabilities;
 };
 
@@ -137,10 +149,12 @@ public slots:
 
 private:
     static bool listContainsDevice(const QList<DeviceInfo> &list, int id);
+    DeviceInfo::SoundSystem soundSystemFromName(const QByteArray &name);
 
 private:
     Backend *m_backend;
     QList<DeviceInfo> m_devices;
+    QMap<DeviceInfo::SoundSystem, QByteArray> m_knownSoundSystems;
 };
 }
 } // namespace Phonon::VLC
diff --git a/src/utils/vstring.h b/src/utils/vstring.h
index e9de06d..a14f934 100644
--- a/src/utils/vstring.h
+++ b/src/utils/vstring.h
@@ -49,6 +49,7 @@ public:
     // VLC internally only uses UTF8!
     QString toQString() { return QString::fromUtf8(m_vlcString); }
     operator QString() { return toQString(); }
+    const char *const_data() const { return m_vlcString; }
 
 private:
     VString() {}


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic