Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. International
  3. Chinese
  4. QAudioDeviceInfo::availableDevices(QAudio::AudioOutput); 非常耗时,不知为何。
Forum Updated to NodeBB v4.3 + New Features

QAudioDeviceInfo::availableDevices(QAudio::AudioOutput); 非常耗时,不知为何。

Scheduled Pinned Locked Moved Unsolved Chinese
1 Posts 1 Posters 539 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • GimInGZG Offline
    GimInGZG Offline
    GimInGZ
    wrote on last edited by
    #1

    需要用到音频输出设备,发现获取可用的音频输出设备的函数非常耗时,每次调用都耗时9秒以上。直接在主线程中使用,导致UI会卡住。是不是只能提前开个线程调用?还是我有什么需要注意的地方?希望有经验的大佬麻烦解答一下。😥

    代码:

    #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();
    }
    

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

    Qt version:
    Qt 5.13.0 MSVC2017 32bit

    OS: Windows 10 (10.0.18362)

    slow and stupid.

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved