Update ALSA device enumeration to return all devices

Previously, if a device was marked as "Default Audio Device" then
only this device would be returned during device enumeration. Now
it returns all devices, with the default device placed first.

Task-number: QTBUG-22103
Change-Id: I1705415bf6b58ff046c4d2812107b46b76500001
Reviewed-by: Michael Goddard <michael.goddard@nokia.com>
This commit is contained in:
Mithra Pattison
2012-06-28 15:40:16 +10:00
committed by Qt by Nokia
parent 53fdcca366
commit 8879945567

View File

@@ -406,7 +406,6 @@ void QAudioDeviceInfoInternal::updateLists()
QList<QByteArray> QAudioDeviceInfoInternal::availableDevices(QAudio::Mode mode)
{
QList<QByteArray> allDevices;
QList<QByteArray> devices;
QByteArray filter;
@@ -436,8 +435,9 @@ QList<QByteArray> QAudioDeviceInfoInternal::availableDevices(QAudio::Mode mode)
if ((descr != NULL) && ((io == NULL) || (io == filter))) {
QString deviceName = QLatin1String(name);
QString deviceDescription = QLatin1String(descr);
allDevices.append(deviceName.toLocal8Bit().constData());
if (deviceDescription.contains(QLatin1String("Default Audio Device")))
devices.prepend(deviceName.toLocal8Bit().constData());
else
devices.append(deviceName.toLocal8Bit().constData());
}
@@ -450,10 +450,6 @@ QList<QByteArray> QAudioDeviceInfoInternal::availableDevices(QAudio::Mode mode)
++n;
}
snd_device_name_free_hint(hints);
if(devices.size() > 0) {
devices.append("default");
}
#else
int idx = 0;
char* name;
@@ -462,13 +458,10 @@ QList<QByteArray> QAudioDeviceInfoInternal::availableDevices(QAudio::Mode mode)
devices.append(name);
idx++;
}
if (idx > 0)
#endif
if (devices.size() > 0)
devices.append("default");
#endif
#if !defined(Q_WS_MAEMO_6)
if (devices.size() == 0 && allDevices.size() > 0)
return allDevices;
#endif
return devices;
}