Index: libkaudiodevicelist/audiodevice_p.h =================================================================== --- libkaudiodevicelist/audiodevice_p.h (revision 740936) +++ libkaudiodevicelist/audiodevice_p.h (working copy) @@ -65,6 +65,7 @@ int subdevice; } alsaId; int index; + QString cardId; int deviceNumber; int initialPreference; bool available : 1; Index: libkaudiodevicelist/audiodeviceenumerator_p.h =================================================================== --- libkaudiodevicelist/audiodeviceenumerator_p.h (revision 740936) +++ libkaudiodevicelist/audiodeviceenumerator_p.h (working copy) @@ -40,6 +40,7 @@ QList playbackdevicelist; QList capturedevicelist; void findDevices(); + void renameDevices(QList *devicelist); KSharedConfig::Ptr config; Index: libkaudiodevicelist/audiodevice.cpp =================================================================== --- libkaudiodevicelist/audiodevice.cpp (revision 740936) +++ libkaudiodevicelist/audiodevice.cpp (working copy) @@ -209,6 +209,7 @@ } QString x_phononId = QLatin1String("x-phonon:CARD=") + handles.first().toString(); // the first is either an int (card number) or a QString (card id) QString fallbackId = QLatin1String("plughw:CARD=") + handles.first().toString(); // the first is either an int (card number) or a QString (card id) + d->cardId = handles.first().toString(); if (handles.size() > 1 && handles.at(1).isValid()) { d->deviceNumber = handles.at(1).toInt(); if (d->deviceNumber == 0) { Index: libkaudiodevicelist/audiodeviceenumerator.cpp =================================================================== --- libkaudiodevicelist/audiodeviceenumerator.cpp (revision 740936) +++ libkaudiodevicelist/audiodeviceenumerator.cpp (working copy) @@ -129,6 +129,9 @@ // ~/.asoundrc and /etc/asound.conf findVirtualDevices(); + renameDevices(&playbackdevicelist); + renameDevices(&capturedevicelist); + //X QFileSystemWatcher *watcher = new QFileSystemWatcher(QCoreApplication::instance()); //X watcher->addPath(QDir::homePath() + QLatin1String("/.asoundrc")); //X watcher->addPath(QLatin1String("/etc/asound.conf")); @@ -264,6 +267,40 @@ #endif //HAS_LIBASOUND_DEVICE_NAME_HINT / HAVE_LIBASOUND2 } +void AudioDeviceEnumeratorPrivate::renameDevices(QList *devicelist) +{ + // This looks horrible but allows us to quickly find out if AudioDevices + // with the same name come from different cards, different devices or both + QHash > > cardNames; + foreach (AudioDevice dev, *devicelist) { + cardNames[dev.d->driver][dev.d->cardName][dev.d->cardId]++; + } + + // We then go through and rename devices by appending card#:device# as appropriate + QList::Iterator device; + for (device = devicelist->begin(); device != devicelist->end(); ++device) { + bool appendCardId = cardNames[device->d->driver][device->d->cardName].count() > 1; + bool appendDeviceNumber = false; + if (device->d->deviceNumber != -1) { + foreach (QString cardId, cardNames[device->d->driver][device->d->cardName].keys()) { + if (cardNames[device->d->driver][device->d->cardName][cardId] > 1) { + appendDeviceNumber = true; + } + } + } + + if (appendCardId || appendDeviceNumber) { + device->d->cardName += QLatin1String(" "); + } + if (appendCardId) { + device->d->cardName += device->d->cardId; + } + if (appendDeviceNumber) { + device->d->cardName += QLatin1String(":") + QString::number(device->d->deviceNumber); + } + } +} + void AudioDeviceEnumeratorPrivate::_k_asoundrcChanged(const QString &file) { Q_UNUSED(file);