Unsolved QAudioDeviceInfo::defaultOutputDevice() is incorrectly null
-
I am building code I wrote myself under Ubuntu 20.04 in Qt Creator 4.11.0 which reports itself as being based on Qt 5.12.8. I'm running this under VMWare. I installed Qt Creator via its Snap, as presented in the 'Ubuntu Software' storefront.
The 'Settings' application shows a sound output device (of Analog Output - ES1371/ES1373 / Creative Labs CT2518 (Audio PCI 6V/128/5200 / Creative CT4810/CT5803/CT5806 [Sound Blaster PCI]), though of course that's just what VMWare is presenting to the virtualised machine). If I hit the 'Test' button and play some of the tests, they are audible.
If I launch Firefox and browse to e.g. Youtube then it also has no problem producing sound.
Tracking down an issue with the Linux build of my Qt project, I added the following slightly redundant code:
qDebug() << "Available devices:" << QAudioDeviceInfo::availableDevices(QAudio::AudioOutput).size(); const QAudioDeviceInfo &defaultDeviceInfo = QAudioDeviceInfo::defaultOutputDevice(); if(defaultDeviceInfo.isNull()) { qDebug() << "No default device"; }
And it dutifully outputs:
Available devices: 0 No default device
Is there anything I can do to look behind that? Why is Qt unable to find an audio device when I clearly have one, and Firefox has no issue taking advantage of it? Is this normal for Qt under X11?
-
Does the audio plugins also be installed by Ubuntu?
On Linux, there should be plugins/audio/libqtaudio_alsa.so and plugins/audio/libqtmedia_pulse.so.
Also, from their name, you can know that they use alsa and pulseaudio as backends.
Do you have either of the libraries installed too?