diff options
author | Kurt Korbatits <kurt.korbatits@nokia.com> | 2009-10-21 04:29:34 (GMT) |
---|---|---|
committer | Kurt Korbatits <kurt.korbatits@nokia.com> | 2009-10-21 04:29:34 (GMT) |
commit | 0cb251e67ae45d8ab5ad715a4bc6dcf89209d2ab (patch) | |
tree | 2a51c970bf8c82a25a0be4490eac58447b853ab7 /src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp | |
parent | dfd6221d960ec8c563a687684000c3a9c4f58079 (diff) | |
download | Qt-0cb251e67ae45d8ab5ad715a4bc6dcf89209d2ab.zip Qt-0cb251e67ae45d8ab5ad715a4bc6dcf89209d2ab.tar.gz Qt-0cb251e67ae45d8ab5ad715a4bc6dcf89209d2ab.tar.bz2 |
Fixed compile issue with alsa < 1.0.14
Support pre 1.0.14 alsa version.
Reviewed-by:Justin McPherson
Diffstat (limited to 'src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp')
-rw-r--r-- | src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp | 40 |
1 files changed, 37 insertions, 3 deletions
diff --git a/src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp b/src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp index 55020a6..e828238 100644 --- a/src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp +++ b/src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp @@ -52,6 +52,8 @@ #include "qaudiodeviceinfo_alsa_p.h" +#include <alsa/version.h> + QT_BEGIN_NAMESPACE QAudioDeviceInfoInternal::QAudioDeviceInfoInternal(QByteArray dev, QAudio::Mode mode) @@ -151,8 +153,19 @@ bool QAudioDeviceInfoInternal::open() int err = 0; QString dev = device; if(!dev.contains(QLatin1String("default"))) { - int idx = snd_card_get_index(dev.toLocal8Bit().constData()); +#if(SND_LIB_MAJOR == 1 && SND_LIB_MINOR == 0 && SND_LIB_SUBMINOR >= 14) + dev = QString(QLatin1String("default:CARD=%1")).arg(dev); +#else + int idx = 0; + char *name; + + while(snd_card_get_name(idx,&name) == 0) { + if(dev.contains(QLatin1String(name))) + break; + idx++; + } dev = QString(QLatin1String("hw:%1,0")).arg(idx); +#endif } if(mode == QAudio::AudioOutput) { err=snd_pcm_open( &handle,dev.toLocal8Bit().constData(),SND_PCM_STREAM_PLAYBACK,0); @@ -184,8 +197,19 @@ bool QAudioDeviceInfoInternal::testSettings(const QAudioFormat& format) const // open() if(!dev.contains(QLatin1String("default"))) { - int idx = snd_card_get_index(dev.toLocal8Bit().constData()); +#if(SND_LIB_MAJOR == 1 && SND_LIB_MINOR == 0 && SND_LIB_SUBMINOR >= 14) + dev = QString(QLatin1String("default:CARD=%1")).arg(dev); +#else + int idx = 0; + char *name; + + while(snd_card_get_name(idx,&name) == 0) { + if(dev.contains(QLatin1String(name))) + break; + idx++; + } dev = QString(QLatin1String("hw:%1,0")).arg(idx); +#endif } if(mode == QAudio::AudioOutput) { err=snd_pcm_open( &handle,dev.toLocal8Bit().constData(),SND_PCM_STREAM_PLAYBACK,0); @@ -362,7 +386,7 @@ QList<QByteArray> QAudioDeviceInfoInternal::deviceList(QAudio::Mode mode) { QList<QByteArray> devices; QByteArray filter; - +#if(SND_LIB_MAJOR == 1 && SND_LIB_MINOR == 0 && SND_LIB_SUBMINOR >= 14) // Create a list of all current audio devices that support mode void **hints, **n; char *name, *descr, *io; @@ -404,7 +428,17 @@ QList<QByteArray> QAudioDeviceInfoInternal::deviceList(QAudio::Mode mode) if(devices.size() > 0) { devices.append("default"); } +#else + int idx = 0; + char* name; + while(snd_card_get_name(idx,&name) == 0) { + devices.append(name); + idx++; + } + if (idx > 0) + devices.append("default"); +#endif return devices; } |