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

"QAudioDeviceInfo::availableDevices(QAudio::AudioOutput)" takes a lot of time.



  • When I use it directly in the main thread, UI will stuck by it for a long time.
    What should I do?

    Truly grateful for your help.

    code:

    #include <QApplication>
    #include <QDateTime>
    #include <QAudioDeviceInfo>
    #include <QDebug>
    
    int main(int argc, char *argv[])
    {
        QApplication a(argc, argv);
    
        QTime time;
        time.start();
        QAudioDeviceInfo::availableDevices(QAudio::AudioOutput);
        qInfo() << time.restart();
    
        QAudioDeviceInfo::availableDevices(QAudio::AudioOutput);
        qInfo() << time.restart();
    
        QAudioDeviceInfo::availableDevices(QAudio::AudioOutput);
        qInfo() << time.restart();
    
        return a.exec();
    }
    

    output:
    262b9642-07d0-4bab-b7f3-8e6194638412-image.png

    Qt version:
    Qt 5.13.0 MSVC2017 32bit

    OS: Windows 10 (10.0.18362)


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    What kind of devices do you have on your machine ? How many of them ?
    Note that QtMultimedia uses platform specific APIs in its backends so it might be something related to your Windows installation.



  • Hi. thank for your reply.
    I dont know what happen……I haven't do anythings but it work fine now.😰
    960f0cf5-15ac-4887-8446-ace840b9918f-image.png

    I have these devices on my machine.

    output devices:
    Speakers(USB Audio Device)
    Speakers/Headset(Realtek High Definition Audio)

    input devices:
    Microphone(USB Audio Device)
    Microphone(Realtek USB2.0 MIC)
    Stereo Mixer(Realtek High Definition Audio)
    Microphone Array(Realtek High Definition Audio)

    3dbfc85c-cf88-4034-9f8a-54a68e3d73c1-image.png


  • Lifetime Qt Champion

    You may have just had a system glitch at some point. Maybe a virus scanner or something like that running while you were hacking and hogging resources.


Log in to reply