summaryrefslogtreecommitdiffstats
path: root/src/multimedia/audio/qaudioinput_alsa_p.cpp
diff options
context:
space:
mode:
authorKurt Korbatits <kurt.korbatits@nokia.com>2009-11-16 02:04:34 (GMT)
committerKurt Korbatits <kurt.korbatits@nokia.com>2009-11-16 02:04:34 (GMT)
commit35c534491ef048abc072d5ebaaecb756fe8f5773 (patch)
treec5a9c3fe35352101158ebcd48eb186beb58fab95 /src/multimedia/audio/qaudioinput_alsa_p.cpp
parent300ab260c96d1e0a28f44d7e6c1d80b6124efd6c (diff)
downloadQt-35c534491ef048abc072d5ebaaecb756fe8f5773.zip
Qt-35c534491ef048abc072d5ebaaecb756fe8f5773.tar.gz
Qt-35c534491ef048abc072d5ebaaecb756fe8f5773.tar.bz2
No audio devices found for Ubuntu with QAudio classes
Changed alsa implementation to present audio devices from alsa. Task-number:QTBUG-5723 Reviewed-by:Justin McPherson
Diffstat (limited to 'src/multimedia/audio/qaudioinput_alsa_p.cpp')
-rw-r--r--src/multimedia/audio/qaudioinput_alsa_p.cpp25
1 files changed, 17 insertions, 8 deletions
diff --git a/src/multimedia/audio/qaudioinput_alsa_p.cpp b/src/multimedia/audio/qaudioinput_alsa_p.cpp
index 8a8f0db..3dbe66c 100644
--- a/src/multimedia/audio/qaudioinput_alsa_p.cpp
+++ b/src/multimedia/audio/qaudioinput_alsa_p.cpp
@@ -52,6 +52,7 @@
#include <QtCore/qcoreapplication.h>
#include "qaudioinput_alsa_p.h"
+#include "qaudiodeviceinfo_alsa_p.h"
QT_BEGIN_NAMESPACE
@@ -80,8 +81,7 @@ QAudioInputPrivate::QAudioInputPrivate(const QByteArray &device, const QAudioFor
pullMode = true;
resuming = false;
- QStringList list1 = QString(QLatin1String(device)).split(QLatin1String(":"));
- m_device = QByteArray(list1.at(0).toLocal8Bit().constData());
+ m_device = device;
timer = new QTimer(this);
connect(timer,SIGNAL(timeout()),SLOT(userFeed()));
@@ -259,22 +259,31 @@ bool QAudioInputPrivate::open()
unsigned int freakuency=settings.frequency();
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()));
+ QList<QByteArray> devices = QAudioDeviceInfoInternal::availableDevices(QAudio::AudioInput);
+ if(dev.compare(QLatin1String("default")) == 0) {
+#if(SND_LIB_MAJOR == 1 && SND_LIB_MINOR == 0 && SND_LIB_SUBMINOR >= 14)
+ dev = QLatin1String(devices.first());
+#else
+ dev = QLatin1String("hw:0,0");
+#endif
+ } else {
+#if(SND_LIB_MAJOR == 1 && SND_LIB_MINOR == 0 && SND_LIB_SUBMINOR >= 14)
+ dev = QLatin1String(m_device);
#else
int idx = 0;
char *name;
+ QString shortName = QLatin1String(m_device.mid(m_device.indexOf('=',0)+1).constData());
+
while(snd_card_get_name(idx,&name) == 0) {
- if(m_device.contains(name))
+ if(qstrncmp(shortName.toLocal8Bit().constData(),name,shortName.length()) == 0)
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);
@@ -614,7 +623,7 @@ qint64 QAudioInputPrivate::elapsedUSecs() const
if (deviceState == QAudio::StoppedState)
return 0;
-#if(SND_LIB_MAJOR == 1 && SND_LIB_MINOR == 0 && SND_LIB_SUBMINOR >= 14)
+#if(SND_LIB_MAJOR == 1 && SND_LIB_MINOR == 0 && SND_LIB_SUBMINOR >= 14)
snd_pcm_status_t* status;
snd_pcm_status_alloca(&status);