diff options
author | Yoann Lopes <yoann.lopes@qt.io> | 2016-05-03 16:01:45 +0200 |
---|---|---|
committer | Yoann Lopes <yoann.lopes@qt.io> | 2016-06-03 09:44:48 +0000 |
commit | 5473621bde2be226f2f3687a80b4bfc93bbbe572 (patch) | |
tree | 9173c937926ab8e0a8af082e02fffd2e5e1e31ce /src/plugins/alsa/qalsaaudiooutput.cpp | |
parent | d76d3184b7407b0ff6d4d8d614a5679736d4aa15 (diff) |
ALSA: improve handling of default device.
- "default" is a valid argument for snd_pcm_open(), let ALSA handle that
case rather than using the first device in the list.
- Don't add "default" in the list of available devices if there is
already one.
Change-Id: Icd41aa6677923a79faf6c90d0627eedd8700b91b
Reviewed-by: Christian Stromme <christian.stromme@qt.io>
Diffstat (limited to 'src/plugins/alsa/qalsaaudiooutput.cpp')
-rw-r--r-- | src/plugins/alsa/qalsaaudiooutput.cpp | 34 |
1 files changed, 8 insertions, 26 deletions
diff --git a/src/plugins/alsa/qalsaaudiooutput.cpp b/src/plugins/alsa/qalsaaudiooutput.cpp index 02681a4df..bf607e057 100644 --- a/src/plugins/alsa/qalsaaudiooutput.cpp +++ b/src/plugins/alsa/qalsaaudiooutput.cpp @@ -303,34 +303,16 @@ bool QAlsaAudioOutput::open() return false; } - QString dev = QString(QLatin1String(m_device.constData())); - QList<QByteArray> devices = QAlsaAudioDeviceInfo::availableDevices(QAudio::AudioOutput); - if(dev.compare(QLatin1String("default")) == 0) { -#if SND_LIB_VERSION >= 0x1000e // 1.0.14 - if (devices.size() > 0) - dev = QLatin1String(devices.first()); - else - return false; -#else - dev = QLatin1String("hw:0,0"); -#endif - } else { -#if SND_LIB_VERSION >= 0x1000e // 1.0.14 - dev = QLatin1String(m_device); -#else - int idx = 0; - char *name; - - QString shortName = QLatin1String(m_device.mid(m_device.indexOf('=',0)+1).constData()); + if (!QAlsaAudioDeviceInfo::availableDevices(QAudio::AudioOutput).contains(m_device)) + return false; - while (snd_card_get_name(idx,&name) == 0) { - if(qstrncmp(shortName.toLocal8Bit().constData(),name,shortName.length()) == 0) - break; - idx++; - } - dev = QString(QLatin1String("hw:%1,0")).arg(idx); + QString dev; +#if SND_LIB_VERSION < 0x1000e // 1.0.14 + if (m_device != "default") + dev = QAlsaAudioDeviceInfo::deviceFromCardName(m_device); + else #endif - } + dev = m_device; // Step 1: try and open the device while((count < 5) && (err < 0)) { |