Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QAudioDeviceInfo misbehaving in Windows 10



  • Hi All,

    I have a very strange problem that doesn't occur when I run my application in release mode inside QtCreator, but only once I package the application and run it from it's own directory (with all its dependencies properly packaged with it). The problem concerns querying the system for the default audio device using QAudioDeviceInfo::defaultOutputDevice(). This works just fine as I said when running inside the IDE.

    For example this bit of code:

       QAudioDeviceInfo info(QAudioDeviceInfo::defaultOutputDevice());
       if (info.isNull())
       {
           qDebug() << "Audio Info is Null " <<  info.deviceName();
       }
       if (!info.isFormatSupported(_format))
       {
           qWarning() << "Audio output format not supported by backend, cannot play audio. " << info.deviceName();
    
           qDebug()<<info.supportedCodecs();
           qDebug()<<info.supportedByteOrders();
           qDebug()<<info.supportedChannelCounts();
           qDebug()<<info.supportedSampleRates();
           qDebug()<<info.supportedSampleSizes();
       }
       else
       {
           qDebug() << "Audio Info is OK! " <<  info.deviceName();
       }
    

    When run in the IDE yields:

    Audio Info is OK!  "Speakers (Realtek High Definition Audio)"
    

    Yet in my GUI app (doctored to have console output) I get:

    Audio Info is Null  ""
    Audio output format not supported by backend, cannot play audio.  ""
    ()
    ()
    ()
    ()
    ()
    

    Very frustrating to try to debug this. I don't have much knowledge of the underlying audio system in Windows, so please if there's something I need to know about the backend, let me know (Qt version is 5.7, using MinGW to build)


  • Lifetime Qt Champion

    Hi,

    Are you using windeployqt to put together the dependencies of your application ?
    Did you deploy the QtMultimedia plugins ?



  • @SGaist Yes. Without that the application would crash on startup.



  • @SGaist Oh... wait... you didn't say library you said plugins... are there plugins to deploy as well? If so it seems windeployqt is not picking them up. Actually I don't think it picks up Qt5Mulimedia dll on its own either come to think of it, i had to add that manually to the package in my .pro files...

    SO what else needs to be in there?



  • @SGaist Yes, plugins was the magic word. I added QTDIR/plugins/audio to my package and it works now. So why does windeployqt not pick up the QtMultimedia stuff?



  • For those wondering, I had to add the --multimedia option to the windeployqt command. I didn't realize there were separate options in windeployqt for each Qt module... guess I should have read the docs more carefully! Thanks to SGaist.


Log in to reply