QAudioDeviceInfo::defaultInputDevice() unexpected behavior
-
Hi guys. I am implementing an audio recorder app with GUI and use QAudioDeviceInfo class for extracting locally available audio input devices. It works correctly, but when I want to extract the default Audio Input device name with QAudioDeviceInfo::defaultInputDevice() it works unexpectedly.
const auto l_deviceInfos = QAudioDeviceInfo::availableDevices(QAudio::AudioInput); const auto l_default = QAudioDeviceInfo::defaultInputDevice().deviceName(); qDebug()<<l_default;// displays "Default Input Device" QAudioDeviceInfo l_elem{}; foreach(l_elem, l_deviceInfos){ ui->cmboxAudioInputs->addItem(l_elem.deviceName(),QVariant::fromValue(l_elem)); //works fine and adds all names of available audio input devices }
Could you please explain what is the problem and how can I handle it? Thanks
-
@haykarmeni What value do you expect?
-
@eyllanesc based on https://doc.qt.io/qt-5/qaudiodeviceinfo.html#deviceName it will return the human-readable name of the audio device, so in this case Microphone (Realtek (R) Audio) as my default audio input device, because when I call
qDebug()
forl_elem.deviceName()
it works fine and displays all names of available devices -
@haykarmeni The docs say: eg. default, Intel, U0x46d0x9a4
-
@eyllanesc, so is there any other way to extract the exact name of the default audio input file? Am I right, that the first element of the returned value of
QAudioDeviceInfo::availableDevices(QAudio::AudioInput)
is theDeviceInfo
of the default audio input device?