summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/phonon/gstreamer
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-12 05:39:38 (GMT)
commit80c24f730c3443e8c05fca374fca365456034fe8 (patch)
treea5f9c43098b280a64594bb5acccbdc4bcc9e8e99 /src/3rdparty/phonon/gstreamer
parentefc566799797a9088628ac21d83ee2d39805fabc (diff)
downloadQt-80c24f730c3443e8c05fca374fca365456034fe8.zip
Qt-80c24f730c3443e8c05fca374fca365456034fe8.tar.gz
Qt-80c24f730c3443e8c05fca374fca365456034fe8.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/gstreamer')
-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