summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/phonon
diff options
context:
space:
mode:
authorJustin McPherson <justin.mcpherson@nokia.com>2009-11-11 03:57:30 (GMT)
committerJustin McPherson <justin.mcpherson@nokia.com>2009-11-11 03:57:30 (GMT)
commit64cc1777b7be9357e6afb334ca837d4f3583927d (patch)
treef547906141a69244a4d2e74a179162d1fed3328f /src/3rdparty/phonon
parenta53fa6a0f933661e99f904d80ed2bd3de2acb2f6 (diff)
downloadQt-64cc1777b7be9357e6afb334ca837d4f3583927d.zip
Qt-64cc1777b7be9357e6afb334ca837d4f3583927d.tar.gz
Qt-64cc1777b7be9357e6afb334ca837d4f3583927d.tar.bz2
Gstreamer: Do not assume that the list index is the same as the device
id. This fix is similar to KDE change 1027568 by cguthrie. This commit fixes a bug that was highlighted when devices had been added/removed or the backend was reloaded. The AudioDevice used to use a static counter to allocate itself a device id that was propigated through the Phonon API. Code in the Backend invalidly assumed that the index in the list was the same as this id.
Diffstat (limited to 'src/3rdparty/phonon')
-rw-r--r--src/3rdparty/phonon/gstreamer/audiooutput.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/3rdparty/phonon/gstreamer/audiooutput.cpp b/src/3rdparty/phonon/gstreamer/audiooutput.cpp
index fcadac2..641ff6b 100644
--- a/src/3rdparty/phonon/gstreamer/audiooutput.cpp
+++ b/src/3rdparty/phonon/gstreamer/audiooutput.cpp
@@ -136,11 +136,19 @@ bool AudioOutput::setOutputDevice(int newDevice)
bool success = false;
const QList<AudioDevice> deviceList = m_backend->deviceManager()->audioOutputDevices();
- if (m_audioSink && newDevice >= 0 && newDevice < deviceList.size()) {
+ int deviceIdx = -1;
+ for (int i=0; i<deviceList.size(); i++) {
+ if (deviceList.at(i).id == newDevice) {
+ deviceIdx = i;
+ break;
+ }
+ }
+
+ if (m_audioSink && deviceIdx >= 0) {
// Save previous state
GstState oldState = GST_STATE(m_audioSink);
const QByteArray oldDeviceValue = GstHelper::property(m_audioSink, "device");
- const QByteArray deviceId = deviceList.at(newDevice).gstId;
+ const QByteArray deviceId = deviceList.at(deviceIdx).gstId;
m_device = newDevice;
// We test if the device can be opened by checking if it can go from NULL to READY state