From dfefd0d05488c5a8c4e0be2c23717407c9b4572e Mon Sep 17 00:00:00 2001 From: Justin McPherson Date: Wed, 11 Nov 2009 13:57:30 +1000 Subject: 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. (cherry picked from commit 80c24f730c3443e8c05fca374fca365456034fe8) --- src/3rdparty/phonon/gstreamer/audiooutput.cpp | 12 ++++++++++-- 1 file 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 deviceList = m_backend->deviceManager()->audioOutputDevices(); - if (m_audioSink && newDevice >= 0 && newDevice < deviceList.size()) { + int deviceIdx = -1; + for (int i=0; i= 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 -- cgit v0.12