Why can't I open my default audio input?
-
wrote on 3 Jun 2022, 04:59 last edited by
Using Qt 5.15 on Windows 10 Pro, this code
const auto deviceInfos = QAudioDeviceInfo::availableDevices(QAudio::AudioInput);
for (const QAudioDeviceInfo &deviceInfo : deviceInfos)
qDebug() << "Device name: " << deviceInfo.deviceName();
qDebug()<< "Default audio input is " << QAudioDeviceInfo::defaultInputDevice().deviceName();
QAudioFormat format;
format.setCodec("audio/pcm");
format.setChannelCount(2);
format.setSampleRate(44100);
format.setSampleType(QAudioFormat::SignedInt);
format.setSampleSize(16);
format.setByteOrder(QAudioFormat::LittleEndian);
QAudioDeviceInfo info(QAudioDeviceInfo::defaultInputDevice());
if (info.isFormatSupported(format))
qDebug() << "Format IS supported";
else
qDebug() << "Format is NOT supported";
QAudioInput *audio = new QAudioInput(format, this);
Q_ASSERT(audio);produces
Device name: "Line In (Realtek(R) Audio)"
Default audio input is "Default Input Device"
Format IS supportedbut when I add
QIODevice *dev = audio->start();it produces
avcore\audiocore\client\audioclient\audioclientcore.cpp(1501)\AUDIOSES.DLL!00...
QAudioInput: failed to open audio deviceAm I doing something wrong?
-
Hi and welcome to devnet,
Might be a silly question but do you have any other application that might be using it ?
-
wrote on 4 Jun 2022, 03:32 last edited by
Ha! I didn't find anyone else using it, but I did find that my privacy settings were set to not allow access by desktop apps. After I changed that, my Qt code was able to open the audio input.
Thanks for the tip!
1/3