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

List:       kde-commits
Subject:    KDE/kdelibs/phonon
From:       Matthias Kretz <kretz () kde ! org>
Date:       2008-04-21 21:22:38
Message-ID: 1208812958.564419.28126.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 799558 by mkretz:

use AudioOutputDevice object to select the device, instead of only the index

 M  +24 -9     audiooutput.cpp  
 M  +22 -3     audiooutputinterface.h  


--- trunk/KDE/kdelibs/phonon/audiooutput.cpp #799557:799558
@@ -26,15 +26,28 @@
 #include "phononnamespace_p.h"
 #include "platform_p.h"
 
-#include <QtCore/qmath.h>
+#include <qmath.h>
 
 #define PHONON_CLASSNAME AudioOutput
-#define PHONON_INTERFACENAME AudioOutputInterface
+#define IFACES2 AudioOutputInterface
+#define IFACES1 IFACES2
+#define IFACES0 AudioOutputInterface0, IFACES1
+#define PHONON_INTERFACENAME IFACES0
 
 QT_BEGIN_NAMESPACE
 
 namespace Phonon
 {
+
+static inline bool callSetOutputDevice(MediaNodePrivate *const d, int index)
+{
+    Iface<IFACES2> iface(d);
+    if (iface) {
+        return iface->setOutputDevice(AudioOutputDevice::fromIndex(index));
+    }
+    return Iface<IFACES0>::cast(d)->setOutputDevice(index);
+}
+
 AudioOutput::AudioOutput(Phonon::Category category, QObject *parent)
     : AbstractAudioOutput(*new AudioOutputPrivate, parent)
 {
@@ -193,7 +206,7 @@
         d->outputDeviceIndex = newAudioOutputDevice.index();
     }
     if (k_ptr->backendObject()) {
-        return INTERFACE_CALL(setOutputDevice(d->outputDeviceIndex));
+        return callSetOutputDevice(k_ptr, d->outputDeviceIndex);
     }
     return true;
 }
@@ -219,7 +232,7 @@
     pINTERFACE_CALL(setVolume(pow(volume, VOLTAGE_TO_LOUDNESS_EXPONENT)));
 
     // if the output device is not available and the device was not explicitly set
-    if (!pINTERFACE_CALL(setOutputDevice(outputDeviceIndex)) && !outputDeviceOverridden) {
+    if (!outputDeviceOverridden && !callSetOutputDevice(this, outputDeviceIndex)) {
         // fall back in the preference list of output devices
         QList<int> deviceList = GlobalConfig().audioOutputDeviceListFor(category);
         if (deviceList.isEmpty()) {
@@ -228,7 +241,7 @@
         if (outputDeviceIndex == deviceList.takeFirst()) { // removing the first device so that
             // if it's the same device as the one we tried we only try all the following
             foreach (int devIndex, deviceList) {
-                if (pINTERFACE_CALL(setOutputDevice(devIndex))) {
+                if (callSetOutputDevice(this, devIndex)) {
                     handleAutomaticDeviceChange(devIndex, AudioOutputPrivate::FallbackChange);
                     break; // found one that works
                 }
@@ -251,7 +264,7 @@
         return;
     }
     outputDeviceIndex = deviceBeforeFallback;
-    pINTERFACE_CALL(setOutputDevice(outputDeviceIndex));
+    callSetOutputDevice(this, outputDeviceIndex);
     Q_Q(AudioOutput);
     emit q->outputDeviceChanged(AudioOutputDevice::fromIndex(outputDeviceIndex));
 }
@@ -265,7 +278,7 @@
     foreach (int devIndex, deviceList) {
         // if it's the same device as the one that failed, ignore it
         if (outputDeviceIndex != devIndex) {
-            if (pINTERFACE_CALL(setOutputDevice(devIndex))) {
+            if (callSetOutputDevice(this, devIndex)) {
                 handleAutomaticDeviceChange(devIndex, FallbackChange);
                 break; // found one that works
             }
@@ -288,7 +301,7 @@
             }
             changeType = FallbackChange;
         }
-        if (pINTERFACE_CALL(setOutputDevice(devIndex))) {
+        if (callSetOutputDevice(this, devIndex)) {
             handleAutomaticDeviceChange(devIndex, changeType);
             break; // found one with higher preference that works
         }
@@ -328,4 +341,6 @@
 
 #undef PHONON_CLASSNAME
 #undef PHONON_INTERFACENAME
-// vim: sw=4 ts=4 tw=100 et
+#undef IFACES2
+#undef IFACES1
+#undef IFACES0
--- trunk/KDE/kdelibs/phonon/audiooutputinterface.h #799557:799558
@@ -21,6 +21,7 @@
 #define PHONON_AUDIOOUTPUTINTERFACE_H
 
 #include "phononnamespace.h"
+#include "objectdescription.h"
 #include <QtCore/QtGlobal>
 
 QT_BEGIN_HEADER
@@ -33,10 +34,10 @@
  *
  * \author Matthias Kretz <kretz@kde.org>
  */
-class AudioOutputInterface
+class AudioOutputInterface0
 {
     public:
-        virtual ~AudioOutputInterface() {}
+        virtual ~AudioOutputInterface0() {}
 
         /**
          * Returns the current software volume.
@@ -59,6 +60,8 @@
          */
         virtual int outputDevice() const = 0;
         /**
+         * \deprecated
+         *
          * Requests to change the current output device to the one identified by the passed index.
          *
          * The index is the number returned from
@@ -69,9 +72,25 @@
          */
         virtual bool setOutputDevice(int) = 0;
 };
+
+class AudioOutputInterface : public AudioOutputInterface0
+{
+    public:
+        /**
+         * Requests to change the current output device.
+         *
+         * \returns \c true if the requested device works and is used after this call.
+         * \returns \c false if something failed and the device is not used after this call.
+         */
+        virtual bool setOutputDevice(const Phonon::AudioOutputDevice &) = 0;
+
+        using AudioOutputInterface0::setOutputDevice;
+};
+
 } // namespace Phonon
 
-Q_DECLARE_INTERFACE(Phonon::AudioOutputInterface, "AudioOutputInterface2.phonon.kde.org")
+Q_DECLARE_INTERFACE(Phonon::AudioOutputInterface0, "AudioOutputInterface2.phonon.kde.org")
+Q_DECLARE_INTERFACE(Phonon::AudioOutputInterface,  "3AudioOutputInterface.phonon.kde.org")
 
 QT_END_NAMESPACE
 QT_END_HEADER
[prev in list] [next in list] [prev in thread] [next in thread] 

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