19 #include <QAudioFormat> 20 #include <QAudioDeviceInfo> 21 #include <QAudioInput> 26 m_mutex(QMutex::Recursive),
39 QMutexLocker mutexLocker(&
m_mutex);
53 QMutexLocker mutexLocker(&
m_mutex);
54 QAudioDeviceInfo devInfo;
58 devInfo = QAudioDeviceInfo::defaultInputDevice();
59 qWarning(
"AudioInput::start: using default device %s", qPrintable(devInfo.defaultInputDevice().deviceName()));
63 QList<QAudioDeviceInfo> devicesInfo = QAudioDeviceInfo::availableDevices(QAudio::AudioInput);
65 if (device < devicesInfo.size())
67 devInfo = devicesInfo[device];
68 qWarning(
"AudioInput::start: using audio device #%d: %s", device, qPrintable(devInfo.deviceName()));
72 devInfo = QAudioDeviceInfo::defaultInputDevice();
73 qWarning(
"AudioInput::start: audio device #%d does not exist. Using default device %s", device, qPrintable(devInfo.deviceName()));
89 qWarning(
"AudioInput::start: %d Hz S16_LE audio format not supported. Nearest is sampleRate: %d channelCount: %d sampleSize: %d sampleType: %d",
94 qInfo(
"AudioInput::start: audio format OK");
99 qWarning(
"AudioInput::start: Audio device '%s' failed", qPrintable(devInfo.defaultInputDevice().deviceName()));
106 QIODevice::open(QIODevice::ReadWrite);
112 qWarning(
"AudioInput::start: cannot start");
123 qDebug(
"AudioInput::stop");
131 qDebug(
"AudioInput::stop: effectively close QIODevice");
132 QMutexLocker mutexLocker(&
m_mutex);
144 QMutexLocker mutexLocker(&
m_mutex);
151 QMutexLocker mutexLocker(&
m_mutex);
173 || (
m_audioFormat.byteOrder() != QAudioFormat::LittleEndian))
175 qCritical(
"AudioInput::writeData: invalid format not S16LE");
180 qCritical(
"AudioInput::writeData: invalid format not stereo");
186 (*it)->write(reinterpret_cast<const quint8*>(data), len/4);