DefaultAudioInput returns non valid audio name?
-
Hello.
For sure i'm missing something, but I cannot solve it.
It's code from Qt official doc. (QAudioRecorder doc,)
@QStringList inputs = audioRecorder->audioInputs();
QString selectedInput = audioRecorder->defaultAudioInput();foreach (QString input, inputs) {
QString description = audioRecorder->audioInputDescription(input);
// show descriptions to user and allow selection
selectedInput = input;
}audioRecorder->setAudioInput(selectedInput);@
The problem is that nor Audio Input names neither audio input description match what defaultAudioInput() returns.
At last in my system (Windows 8) it is "Default Input Device" and I'm not able to know wich input device is the default one.Is there any way to know it?
Furthermore, if you try to create a input using "Default Input Device" name, doesn't works. So, it's imperative for me to know that correct default input device name.
-
Up!
Nobody knows answer or am I completly wrong and nobody wants to enlight me? XDDD
-
Hi,
It might also be that not many people are currently using Windows 8 for development.
Default Input Device should correspond to your mixer default input device, you can take a look at it there.
IIRC, you can use QAudioDeviceInfo::defaultInputDevice() when you want to create the default device.
-
Hi SGaist. Thankyou for your interest.
Yes, I can use that function to create a default audio device and works fine.
But the problem persists as there is no way to know the real name for "Default audio device". So, I cannot select correct device in the ComboBox.I will take a look on other OS.
-
You can use QAudioDeviceInfo::availableDevices to get a list of all devices and build your combo box with it. IIRC the default device will be named "default" so you don't have to worry about that
-
No, thats the problem.... there is no "default" named device in list.
Look at this to see what I'm saying.
!http://s2.postimg.org/88vfoc1gp/avaiable_Devices.png(avaiableDevices)!
It's a debug image from audioinput example, audioinput.cpp fileAs you can see, there is only one device in system with his "real name"
And here, in m_device variable, obtained by defaultInputDevice(), you can see the name ... "Default..."
!http://s28.postimg.org/cuuun268t/default_Input_Device.png(defaultInputDevice)!I've checked in Windows XP, and defaultInputDevice() returns real name. So, it's a W8 issue. I will check it in W7 and OS-X. Oh, great W8!!!! :/
-
That's pretty strange indeed, can you check what happens if you have more than one audio device ? e.g. usb audio card, bluetooth headset etc… ?
-
I've just hit this too.
The only way I see around this is to have platform specific code on Windows that puts an extra entry in my audio device choice combo box and more platform specific code in the changed action to detect the default entry and open the device by re-fetching the default.
Does the "Default (Input|Output) Device" get looked up at program startup or is it dynamic and track changes at he o/s level while the application runs?
-
[quote author="bsomervi" date="1392160785"]I've just hit this too.
The only way I see around this is to have platform specific code on Windows that puts an extra entry in my audio device choice combo box and more platform specific code in the changed action to detect the default entry and open the device by re-fetching the default.
Does the "Default (Input|Output) Device" get looked up at program startup or is it dynamic and track changes at he o/s level while the application runs?[/quote]
plataform-specific code could be the solution, but keep in mind that the plataform is not "Windows" but "Windows 8". Perhaps, using WinAPI in a different way that Qt does, we'll be able to know default audio device name in all windows versions.
I'm happy not being alone xD
-
I have worked around this without having to write any platform specific code. I had to assume that the special device names "Default Input Device" and "Default Output Device" will never appear on any platform unless they are really a "default" device since there doesn't seem to be a way of identifying a saved QAudioDeviceInfo object (reflecting a user choice) as the "default" one.
To answer my other question - both the default devices and the whole QAudioDeviceInfo::availableDevices(...) lists are "live" and reflect the current system state at all times. This fact means that my code to work with the special "default" devices was required anyway to recognize that the user may have changed the default or plugged/unplugged a device between one stream start() call and the next.