[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-22 10:33:12
Message-ID: 1208860392.215623.4221.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 799786 by mkretz:
- less AudioOutputDevice::fromIndex calls
- better logic for handling a device list change
- ignore unavailable devices in device failure handler
M +34 -17 audiooutput.cpp
M +1 -1 audiooutput_p.h
--- trunk/KDE/kdelibs/phonon/audiooutput.cpp #799785:799786
@@ -48,6 +48,15 @@
return Iface<IFACES0>::cast(d)->setOutputDevice(index);
}
+static inline bool callSetOutputDevice(MediaNodePrivate *const d, const \
AudioOutputDevice &dev) +{
+ Iface<IFACES2> iface(d);
+ if (iface) {
+ return iface->setOutputDevice(dev);
+ }
+ return Iface<IFACES0>::cast(d)->setOutputDevice(dev.index());
+}
+
AudioOutput::AudioOutput(Phonon::Category category, QObject *parent)
: AbstractAudioOutput(*new AudioOutputPrivate, parent)
{
@@ -242,7 +251,7 @@
// if it's the same device as the one we tried we only try all the \
following foreach (int devIndex, deviceList) {
if (callSetOutputDevice(this, devIndex)) {
- handleAutomaticDeviceChange(devIndex, \
AudioOutputPrivate::FallbackChange); + \
handleAutomaticDeviceChange(AudioOutputDevice::fromIndex(devIndex), \
AudioOutputPrivate::FallbackChange); break; // found one that works
}
}
@@ -278,9 +287,12 @@
foreach (int devIndex, deviceList) {
// if it's the same device as the one that failed, ignore it
if (outputDeviceIndex != devIndex) {
- if (callSetOutputDevice(this, devIndex)) {
- handleAutomaticDeviceChange(devIndex, FallbackChange);
- break; // found one that works
+ const AudioOutputDevice info = AudioOutputDevice::fromIndex(devIndex);
+ if (info.property("available").toBool()) {
+ if (callSetOutputDevice(this, info)) {
+ handleAutomaticDeviceChange(info, FallbackChange);
+ break; // found one that works
+ }
}
}
}
@@ -293,30 +305,35 @@
QList<int> deviceList = GlobalConfig().audioOutputDeviceListFor(category);
DeviceChangeType changeType = HigherPreferenceChange;
foreach (int devIndex, deviceList) {
- pDebug() << devIndex;
- if (outputDeviceIndex == devIndex) {
- AudioOutputDevice info = AudioOutputDevice::fromIndex(devIndex);
- if (info.property("available").toBool()) {
- break; // we've reached the currently used device, nothing to change
+ const AudioOutputDevice info = AudioOutputDevice::fromIndex(devIndex);
+ if (!info.property("available").toBool()) {
+ if (outputDeviceIndex == devIndex) {
+ // we've reached the currently used device
+ changeType = FallbackChange;
}
- changeType = FallbackChange;
+ pDebug() << devIndex << "is not available";
+ continue;
}
- if (callSetOutputDevice(this, devIndex)) {
- handleAutomaticDeviceChange(devIndex, changeType);
+ pDebug() << devIndex << "is available";
+ if (outputDeviceIndex == devIndex) {
+ // we've reached the currently used device, nothing to change
+ break;
+ }
+ if (callSetOutputDevice(this, info)) {
+ handleAutomaticDeviceChange(info, changeType);
break; // found one with higher preference that works
}
}
}
-void AudioOutputPrivate::handleAutomaticDeviceChange(int newIndex, DeviceChangeType \
type) +void AudioOutputPrivate::handleAutomaticDeviceChange(const AudioOutputDevice \
&device2, DeviceChangeType type) {
Q_Q(AudioOutput);
deviceBeforeFallback = outputDeviceIndex;
- outputDeviceIndex = newIndex;
- emit q->outputDeviceChanged(AudioOutputDevice::fromIndex(outputDeviceIndex));
+ outputDeviceIndex = device2.index();
+ emit q->outputDeviceChanged(device2);
QString text;
- AudioOutputDevice device1 = AudioOutputDevice::fromIndex(deviceBeforeFallback);
- AudioOutputDevice device2 = AudioOutputDevice::fromIndex(outputDeviceIndex);
+ const AudioOutputDevice &device1 = \
AudioOutputDevice::fromIndex(deviceBeforeFallback); switch (type) {
case FallbackChange:
text = AudioOutput::tr("<html>The audio playback device <b>%1</b> does not \
work.<br/>"
--- trunk/KDE/kdelibs/phonon/audiooutput_p.h #799785:799786
@@ -60,7 +60,7 @@
FallbackChange,
HigherPreferenceChange
};
- void handleAutomaticDeviceChange(int newIndex, DeviceChangeType type);
+ void handleAutomaticDeviceChange(const AudioOutputDevice &newDev, \
DeviceChangeType type);
void _k_volumeChanged(qreal);
void _k_revertFallback();
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic