summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKurt Korbatits <kurt.korbatits@nokia.com>2009-10-21 04:29:34 (GMT)
committerKurt Korbatits <kurt.korbatits@nokia.com>2009-10-21 04:29:34 (GMT)
commit0cb251e67ae45d8ab5ad715a4bc6dcf89209d2ab (patch)
tree2a51c970bf8c82a25a0be4490eac58447b853ab7
parentdfd6221d960ec8c563a687684000c3a9c4f58079 (diff)
downloadQt-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
-rw-r--r--src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp40
-rw-r--r--src/multimedia/audio/qaudioinput_alsa_p.cpp19
-rw-r--r--src/multimedia/audio/qaudioinput_alsa_p.h1
-rw-r--r--src/multimedia/audio/qaudiooutput_alsa_p.cpp17
-rw-r--r--src/multimedia/audio/qaudiooutput_alsa_p.h1
5 files changed, 74 insertions, 4 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;
}
diff --git a/src/multimedia/audio/qaudioinput_alsa_p.cpp b/src/multimedia/audio/qaudioinput_alsa_p.cpp
index 5e9aa81..6786657 100644
--- a/src/multimedia/audio/qaudioinput_alsa_p.cpp
+++ b/src/multimedia/audio/qaudioinput_alsa_p.cpp
@@ -249,6 +249,7 @@ bool QAudioInputPrivate::open()
QTime now(QTime::currentTime());
qDebug()<<now.second()<<"s "<<now.msec()<<"ms :open()";
#endif
+ clockStamp.restart();
timeStamp.restart();
elapsedTimeOffset = 0;
@@ -259,9 +260,21 @@ bool QAudioInputPrivate::open()
QString dev = QString(QLatin1String(m_device.constData()));
if(!dev.contains(QLatin1String("default"))) {
+#if(SND_LIB_MAJOR == 1 && SND_LIB_MINOR == 0 && SND_LIB_SUBMINOR >= 14)
dev = QString(QLatin1String("default:CARD=%1")).arg(QLatin1String(m_device.constData()));
- }
+#else
+ int idx = 0;
+ char *name;
+ while(snd_card_get_name(idx,&name) == 0) {
+ if(m_device.contains(name))
+ break;
+ idx++;
+ }
+ dev = QString(QLatin1String("hw:%1,0")).arg(idx);
+#endif
+ }
+
// Step 1: try and open the device
while((count < 5) && (err < 0)) {
err=snd_pcm_open(&handle,dev.toLocal8Bit().constData(),SND_PCM_STREAM_CAPTURE,0);
@@ -601,6 +614,7 @@ qint64 QAudioInputPrivate::clock() const
if (deviceState == QAudio::StopState)
return 0;
+#if(SND_LIB_MAJOR == 1 && SND_LIB_MINOR == 0 && SND_LIB_SUBMINOR >= 14)
snd_pcm_status_t* status;
snd_pcm_status_alloca(&status);
@@ -619,6 +633,9 @@ qint64 QAudioInputPrivate::clock() const
return ((t1.tv_sec * 1000)+l/1000);
} else
return 0;
+#else
+ return clockStamp.elapsed()*1000;
+#endif
}
void QAudioInputPrivate::reset()
diff --git a/src/multimedia/audio/qaudioinput_alsa_p.h b/src/multimedia/audio/qaudioinput_alsa_p.h
index 5583ea0..2ed7453 100644
--- a/src/multimedia/audio/qaudioinput_alsa_p.h
+++ b/src/multimedia/audio/qaudioinput_alsa_p.h
@@ -117,6 +117,7 @@ private:
QTimer* timer;
QTime timeStamp;
+ QTime clockStamp;
qint64 elapsedTimeOffset;
int intervalTime;
char* audioBuffer;
diff --git a/src/multimedia/audio/qaudiooutput_alsa_p.cpp b/src/multimedia/audio/qaudiooutput_alsa_p.cpp
index d814d97..efa7b27 100644
--- a/src/multimedia/audio/qaudiooutput_alsa_p.cpp
+++ b/src/multimedia/audio/qaudiooutput_alsa_p.cpp
@@ -282,7 +282,19 @@ bool QAudioOutputPrivate::open()
QString dev = QLatin1String(m_device.constData());
if(!dev.contains(QLatin1String("default"))) {
+#if(SND_LIB_MAJOR == 1 && SND_LIB_MINOR == 0 && SND_LIB_SUBMINOR >= 14)
dev = QString(QLatin1String("default:CARD=%1")).arg(QLatin1String(m_device.constData()));
+#else
+ int idx = 0;
+ char *name;
+
+ while(snd_card_get_name(idx,&name) == 0) {
+ if(m_device.contains(name))
+ break;
+ idx++;
+ }
+ dev = QString(QLatin1String("hw:%1,0")).arg(idx);
+#endif
}
// Step 1: try and open the device
while((count < 5) && (err < 0)) {
@@ -407,6 +419,7 @@ bool QAudioOutputPrivate::open()
// Step 6: Start audio processing
timer->start(period_time/1000);
+ clockStamp.restart();
timeStamp.restart();
elapsedTimeOffset = 0;
errorState = QAudio::NoError;
@@ -653,6 +666,7 @@ qint64 QAudioOutputPrivate::clock() const
if (deviceState == QAudio::StopState)
return 0;
+#if(SND_LIB_MAJOR == 1 && SND_LIB_MINOR == 0 && SND_LIB_SUBMINOR >= 14)
snd_pcm_status_t* status;
snd_pcm_status_alloca(&status);
@@ -671,6 +685,9 @@ qint64 QAudioOutputPrivate::clock() const
return ((t1.tv_sec * 1000)+l/1000);
} else
return 0;
+#else
+ return clockStamp.elapsed()*1000;
+#endif
return 0;
}
diff --git a/src/multimedia/audio/qaudiooutput_alsa_p.h b/src/multimedia/audio/qaudiooutput_alsa_p.h
index 6d4177d..298e89e 100644
--- a/src/multimedia/audio/qaudiooutput_alsa_p.h
+++ b/src/multimedia/audio/qaudiooutput_alsa_p.h
@@ -134,6 +134,7 @@ private:
QByteArray m_device;
int bytesAvailable;
QTime timeStamp;
+ QTime clockStamp;
qint64 elapsedTimeOffset;
char* audioBuffer;
snd_pcm_t* handle;