src/3rdparty/phonon/gstreamer/audiooutput.cpp
changeset 3 41300fa6a67c
parent 0 1918ee327afb
child 30 5dc02b23752f
--- a/src/3rdparty/phonon/gstreamer/audiooutput.cpp	Tue Jan 26 12:42:25 2010 +0200
+++ b/src/3rdparty/phonon/gstreamer/audiooutput.cpp	Tue Feb 02 00:43:10 2010 +0200
@@ -42,7 +42,6 @@
     static int count = 0;
     m_name = "AudioOutput" + QString::number(count++);
     if (m_backend->isValid()) {
-        g_set_application_name(qApp->applicationName().toUtf8());
         m_audioBin = gst_bin_new (NULL);
         gst_object_ref (GST_OBJECT (m_audioBin));
         gst_object_sink (GST_OBJECT (m_audioBin));     
@@ -137,11 +136,19 @@
 
     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