[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-24 19:24:10
Message-ID: 1209065050.507508.12253.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 800748 by mkretz:

filter out devices with isHardwareDevice set, if the platform plugin provides a list \
of devices already

 M  +33 -9     globalconfig.cpp  


--- trunk/KDE/kdelibs/phonon/globalconfig.cpp #800747:800748
@@ -45,15 +45,31 @@
 {
 }
 
-static void filterAdvanced(BackendInterface *backendIface, QList<int> *list)
+enum WhatToFilter {
+    FilterAdvancedDevices = 1,
+    FilterHardwareDevices = 2
+};
+
+static void filter(ObjectDescriptionType type, BackendInterface *backendIface, \
QList<int> *list, int whatToFilter)  {
     QMutableListIterator<int> it(*list);
     while (it.hasNext()) {
-        const QHash<QByteArray, QVariant> properties = \
                backendIface->objectDescriptionProperties(Phonon::AudioOutputDeviceType, \
                it.next());
-        QVariant var = properties.value("isAdvanced");
-        if (var.isValid() && var.toBool()) {
-            it.remove();
+        const QHash<QByteArray, QVariant> properties = \
backendIface->objectDescriptionProperties(type, it.next()); +        QVariant var;
+        if (whatToFilter & FilterAdvancedDevices) {
+            var = properties.value("isAdvanced");
+            if (var.isValid() && var.toBool()) {
+                it.remove();
+                continue;
+            }
         }
+        if (whatToFilter & FilterHardwareDevices) {
+            var = properties.value("isHardwareDevice");
+            if (var.isValid() && var.toBool()) {
+                it.remove();
+                continue;
+            }
+        }
     }
 }
 
@@ -133,8 +149,12 @@
     if (backendIface) {
         // this list already is in default order (as defined by the backend)
         QList<int> list = \
                backendIface->objectDescriptionIndexes(Phonon::AudioOutputDeviceType);
                
-        if (hideAdvancedDevices) {
-            filterAdvanced(backendIface, &list);
+        if (hideAdvancedDevices || !defaultList.isEmpty()) {
+            filter(AudioOutputDeviceType, backendIface, &list,
+                    (hideAdvancedDevices ? FilterAdvancedDevices : 0)
+                    // the platform plugin already provided the hardware devices
+                    | (defaultList.isEmpty() ? 0 : FilterHardwareDevices)
+                    );
         }
         defaultList += list;
     }
@@ -181,8 +201,12 @@
     if (backendIface) {
         // this list already is in default order (as defined by the backend)
         QList<int> list = \
                backendIface->objectDescriptionIndexes(Phonon::AudioCaptureDeviceType);
                
-        if (hideAdvancedDevices) {
-            filterAdvanced(backendIface, &list);
+        if (hideAdvancedDevices || !defaultList.isEmpty()) {
+            filter(AudioCaptureDeviceType, backendIface, &list,
+                    (hideAdvancedDevices ? FilterAdvancedDevices : 0)
+                    // the platform plugin already provided the hardware devices
+                    | (defaultList.isEmpty() ? 0 : FilterHardwareDevices)
+                  );
         }
         defaultList += list;
     }


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

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