Git commit 1949d7c236eee6bd7e7a74f71e1b228d84e4cbab by Casian Andrei. Committed on 25/07/2014 at 08:17. Pushed by casianandrei into branch 'five'. Remove the DeviceManager class which is not useful for Phonon5 M +0 -1 src/CMakeLists.txt M +0 -3 src/backend.cpp M +0 -5 src/backend.h D +0 -261 src/devicemanager.cpp D +0 -137 src/devicemanager.h http://commits.kde.org/phonon-vlc/1949d7c236eee6bd7e7a74f71e1b228d84e4cbab diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 2259a61..bc08da2 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -23,7 +23,6 @@ set(phonon_vlc_SRCS # audio/audiodataoutput.cpp # audio/volumefadereffect.cpp backend.cpp - devicemanager.cpp connector.cpp # effect.cpp # effectmanager.cpp diff --git a/src/backend.cpp b/src/backend.cpp index 4806883..80798ff 100644 --- a/src/backend.cpp +++ b/src/backend.cpp @@ -33,7 +33,6 @@ //#include "audio/audiodataoutput.h" //#include "audio/volumefadereffect.h" #include "connector.h" -#include "devicemanager.h" //#include "effect.h" //#include "effectmanager.h" #include "player.h" @@ -51,7 +50,6 @@ Backend *Backend::self; = Backend::Backend(QObject *parent, const QVariantList &) : QObject(parent) - , m_deviceManager(0) // , m_effectManager(0) { self =3D this; @@ -105,7 +103,6 @@ Backend::Backend(QObject *parent, const QVariantList &) pFatal("Phonon::VLC::vlcInit: Failed to initialize VLC"); } = - m_deviceManager =3D new DeviceManager(this); // m_effectManager =3D new EffectManager(this); } = diff --git a/src/backend.h b/src/backend.h index 2a9442e..b4f2996 100644 --- a/src/backend.h +++ b/src/backend.h @@ -31,7 +31,6 @@ class LibVLC; namespace Phonon { namespace VLC { = -class DeviceManager; class EffectManager; = /** \brief Backend class for Phonon-VLC. @@ -69,9 +68,6 @@ public: Backend(QObject *parent =3D 0, const QVariantList & =3D QVariantList()= ); ~Backend(); = - /** \return The device manager that is associated with this backend ob= ject. */ - DeviceManager *deviceManager() const; - /** \return The effect manager that is associated with this backend ob= ject. */ EffectManager *effectManager() const; = @@ -86,7 +82,6 @@ public: QObject *createObject(BackendInterface::Class, QObject *parent, const = QList &args); = private: - DeviceManager *m_deviceManager; EffectManager *m_effectManager; }; = diff --git a/src/devicemanager.cpp b/src/devicemanager.cpp deleted file mode 100644 index 4de7d83..0000000 --- a/src/devicemanager.cpp +++ /dev/null @@ -1,261 +0,0 @@ -/* - Copyright (C) 2007-2008 Tanguy Krotoff - Copyright (C) 2008 Lukas Durfina - Copyright (C) 2009 Fathi Boudra - Copyright (C) 2009-2010 vlc-phonon AUTHORS - Copyright (C) 2011 Harald Sitter - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#include "devicemanager.h" - -#include - -#include "backend.h" -#include "utils/debug.h" -#include "utils/libvlc.h" -#include "utils/vstring.h" - -namespace Phonon { -namespace VLC { - -/* - * Device Info - */ - -DeviceInfo::DeviceInfo(const QString &name, bool isAdvanced) -{ - // Get an id - static int counter =3D 0; - m_id =3D counter++; - - // Get name and description for the device - m_name =3D name; - m_isAdvanced =3D isAdvanced; - m_capabilities =3D None; - - // A default device should never be advanced - if (name.startsWith(QLatin1String("default"), Qt::CaseInsensitive)) - m_isAdvanced =3D false; -} - -int DeviceInfo::id() const -{ - return m_id; -} - -const QString& DeviceInfo::name() const -{ - return m_name; -} - -const QString& DeviceInfo::description() const -{ - return m_description; -} - -bool DeviceInfo::isAdvanced() const -{ - return m_isAdvanced; -} - -void DeviceInfo::setAdvanced(bool advanced) -{ - m_isAdvanced =3D advanced; -} - -DeviceInfo::SoundSystem DeviceInfo::soundSystem() const -{ - return m_soundSystem; -} - -QByteArray DeviceInfo::deviceName() const -{ - return m_deviceName; -} - -void DeviceInfo::setAccessInfo(SoundSystem soundSystem, const QByteArray &= deviceName) -{ - m_soundSystem =3D soundSystem; - m_deviceName =3D deviceName; -} - -quint16 DeviceInfo::capabilities() const -{ - return m_capabilities; -} - -void DeviceInfo::setCapabilities(quint16 cap) -{ - m_capabilities =3D cap; -} - - -/* - * Device Manager - */ - -DeviceManager::DeviceManager(Backend *parent) - : QObject(parent) - , m_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("direct= sound")); - m_knownSoundSystems.insert(DeviceInfo::Auhal, QByteArray("auhal")); - - updateDeviceList(); -} - -DeviceManager::~DeviceManager() -{ -} - -const DeviceInfo *DeviceManager::device(int id) const -{ - for (int i =3D 0; i < m_devices.size(); i ++) { - if (m_devices[i].id() =3D=3D id) - return &m_devices[i]; - } - - return NULL; -} - -static QList vlcAudioOutBackends() -{ - QList ret; - - VLC_FOREACH_LIST(audio_output, aout) { - QByteArray name(aout->psz_name); - if (!ret.contains(name)) - ret.append(name); - } - - return ret; -} - -void DeviceManager::updateDeviceList() -{ - DEBUG_BLOCK; - QList newDeviceList; - - if (!LibVLC::self || !libvlc) - return; - - QList audioOutBackends =3D vlcAudioOutBackends(); - - // If we have pulse, screw the rest. - if (audioOutBackends.contains("pulse")) { - DeviceInfo defaultAudioOutputDevice(tr("Default"), false); - defaultAudioOutputDevice.setCapabilities(DeviceInfo::AudioOutput); - defaultAudioOutputDevice.setAccessInfo(DeviceInfo::Pulse, "default= "); - newDeviceList.append(defaultAudioOutputDevice); - return; - } - - // NOTE: if listing was not intercepted by the PA code above we also n= eed - // to try injecting the pulse aout as otherwise the user would h= ave to - // use the fake PA device in ALSA to output through PA (kind of = silly). - - foreach (const QByteArray &soundSystemName, m_knownSoundSystems.values= ()) { - if (!audioOutBackends.contains(soundSystemName)) { - pDebug() << "Sound system" << soundSystemName << "not supporte= d by libvlc"; - continue; - } - - const int deviceCount =3D libvlc_audio_output_device_count(libvlc,= soundSystemName); - - for (int i =3D 0; i < deviceCount; i++) { - VString idName(libvlc_audio_output_device_id(libvlc, soundSyst= emName, i)); - VString longName(libvlc_audio_output_device_longname(libvlc, s= oundSystemName, i)); - - pDebug() << "found device" << soundSystemName << idName << lon= gName; - - DeviceInfo device(longName, true); - device.setAccessInfo(soundSystemFromName(soundSystemName), idN= ame.const_data()); - device.setCapabilities(DeviceInfo::AudioOutput); - newDeviceList.append(device); - } - - // libVLC gives no devices for some sound systems, like OSS - if (deviceCount =3D=3D 0) { - pDebug() << "manually injecting sound system" << soundSystemNa= me; - // 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(soundSystemName), false); - device.setAccessInfo(soundSystemFromName(soundSystemName), ""); - device.setCapabilities(DeviceInfo::AudioOutput); - newDeviceList.append(device); - } - } - - /* - * Compares the list with the devices available at the moment with the= last list. If - * a new device is seen, a signal is emitted. If a device disappeared,= another signal - * is emitted. - */ - - // Search for added devices - for (int i =3D 0; i < newDeviceList.count(); ++i) { - int id =3D newDeviceList[i].id(); - if (!listContainsDevice(m_devices, id)) { - // This is a new device, add it - m_devices.append(newDeviceList[i]); - emit deviceAdded(id); - - pDebug() << "Added backend device" << newDeviceList[i].name(); - } - } - - // Search for removed devices - for (int i =3D m_devices.count() - 1; i >=3D 0; --i) { - int id =3D m_devices[i].id(); - if (!listContainsDevice(newDeviceList, id)) { - emit deviceRemoved(id); - m_devices.removeAt(i); - } - } -} - -bool DeviceManager::listContainsDevice(const QList &list, int = id) -{ - foreach (const DeviceInfo &d, list) { - if (d.id() =3D=3D id) - return true; - } - return false; -} - -DeviceInfo::SoundSystem DeviceManager::soundSystemFromName(const QByteArra= y &name) -{ - foreach (DeviceInfo::SoundSystem soundSystem, m_knownSoundSystems.keys= ()) { - if (m_knownSoundSystems.value(soundSystem) =3D=3D name) - return soundSystem; - } - - return DeviceInfo::UnknownSoundSystem; -} - -} -} diff --git a/src/devicemanager.h b/src/devicemanager.h deleted file mode 100644 index 0ae0e87..0000000 --- a/src/devicemanager.h +++ /dev/null @@ -1,137 +0,0 @@ -/* - Copyright (C) 2009-2010 vlc-phonon AUTHORS - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#ifndef Phonon_VLC_DEVICEMANAGER_H -#define Phonon_VLC_DEVICEMANAGER_H - -#include -#include - -namespace Phonon { -namespace VLC { - -class Backend; - -/** \brief Container for information about devices supported by libVLC - * - * It includes a (hopefully unique) device identifier, a name identifier, a - * description, a hardware identifier (may be a platform dependent device = name), - * and other relevant info. - */ -class DeviceInfo -{ -public: - enum Capability { - None =3D 0x0000, - AudioOutput =3D 0x0001, - AudioCapture =3D 0x0002, - VideoCapture =3D 0x0004 - }; - enum SoundSystem { - UnknownSoundSystem =3D 0, - Pulse, - Alsa, - Oss, - Jack, - Aout_DirectX, - DirectSound, - Auhal - }; -public: - /** - * Constructs a device info object and sets it's device identifiers. - */ - explicit DeviceInfo(const QString &name, bool isAdvanced =3D true); - - int id() const; - const QString& name() const; - const QString& description() const; - bool isAdvanced() const; - void setAdvanced(bool advanced); - SoundSystem soundSystem() const; - QByteArray deviceName() const; - void setAccessInfo(SoundSystem soundSystem, const QByteArray &deviceNa= me); - quint16 capabilities() const; - void setCapabilities(quint16 cap); - -private: - int m_id; - QString m_name; - QString m_description; - bool m_isAdvanced; - SoundSystem m_soundSystem; - QByteArray m_deviceName; - quint16 m_capabilities; -}; - -/** \brief Keeps track of audio/video devices that libVLC supports - * - * This class maintains a device list. Types of devices: - * \li audio output devices - * \li audio capture devices - * \li video capture devices - * - * Methods are provided to retrieve information about these devices. - * - * \see EffectManager - */ -class DeviceManager : public QObject -{ - Q_OBJECT - -public: - /** - * Constructs a device manager and immediately updates the devices. - */ - explicit DeviceManager(Backend *parent); - - /** - * Clears all the devices before destroying. - */ - virtual ~DeviceManager(); - - /** - * \param id The identifier for the device - * \return Pointer to DeviceInfo, or NULL if the id is invalid - */ - const DeviceInfo *device(int id) const; - -signals: - void deviceAdded(int); - void deviceRemoved(int); - -public slots: - /** - * Update the current list of active devices. It probes for audio outp= ut devices, - * audio capture devices, video capture devices. The methods depend on= the - * device types. - */ - void updateDeviceList(); - -private: - static bool listContainsDevice(const QList &list, int id); - DeviceInfo::SoundSystem soundSystemFromName(const QByteArray &name); - -private: - Backend *m_backend; - QList m_devices; - QMap m_knownSoundSystems; -}; -} -} // namespace Phonon::VLC - -#endif // Phonon_VLC_DEVICEMANAGER_H