From cc6406d4971c5656fc4b3eb53f96058a9640c6f7 Mon Sep 17 00:00:00 2001 From: Justin McPherson Date: Wed, 11 Nov 2009 13:54:41 +1000 Subject: Gstreamer: Do not assume that the list index is the same as the device id. Integrated 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. --- src/3rdparty/phonon/gstreamer/backend.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/3rdparty/phonon/gstreamer/backend.cpp b/src/3rdparty/phonon/gstreamer/backend.cpp index 7a06378..dab6f35 100644 --- a/src/3rdparty/phonon/gstreamer/backend.cpp +++ b/src/3rdparty/phonon/gstreamer/backend.cpp @@ -294,10 +294,13 @@ QHash Backend::objectDescriptionProperties(ObjectDescripti switch (type) { case Phonon::AudioOutputDeviceType: { QList audioDevices = deviceManager()->audioOutputDevices(); - if (index >= 0 && index < audioDevices.size()) { - ret.insert("name", audioDevices[index].gstId); - ret.insert("description", audioDevices[index].description); - ret.insert("icon", QLatin1String("audio-card")); + foreach(const AudioDevice &device, audioDevices) { + if (device.id == index) { + ret.insert("name", device.gstId); + ret.insert("description", device.description); + ret.insert("icon", QLatin1String("audio-card")); + break; + } } } break; -- cgit v0.12