Default QAudioDevice (or null)?
-
I find the documentation and the behaviour of the code for
QAudioDevice
confusing.The doc says that the default constructor of
QAudioDevice
creates anull
devicehttps://doc.qt.io/qt-6/qaudiodevice.html#QAudioDevice
The doc, of
QAudioSink
says that this constructor will use the default audio device: https://doc.qt.io/qt-6/qaudiosink.html#QAudioSinkThe corresponding code is: https://github.com/qt/qtmultimedia/blob/a81ad78773995fb840f0cc3d22329be9e73ae3a2/src/multimedia/audio/qaudiosink.cpp#L78
The 2 statements are in contradiction, since
{}
creates anull
device, not the default?Does it matter? Sometimes yes. On my PC
default
ornull
seems to be the same, but on some of my users,null
(i.e.{}
) produces no sound, while if I useQMediaDevices::defaultAudioOutput()
I get the real default device which plays audio.Since
QAudioSink
lacks the ability to tell which audio device it is exactly using, a lot of the above is reverse engineered.What I am saying is that
QAudioSink(QMediaDevices::defaultAudioOutput(), format);
and
QAudioSink(format);
are not the same, contrary to what the doc says.
Regards
-
Hi,
Your analysis looks correct. The default QAudioOutput constructor does indeed use the default output but in this case, it's the QAudioDevice constructor that is called.
You should check the bug report system to see if there's already something about and if not, please open a new ticket.