【问题标题】:How to retrieve the audio input and output device names in a Linux system?如何在 Linux 系统中检索音频输入和输出设备名称?
【发布时间】:2021-04-22 03:59:09
【问题描述】:

我正在 Debian Linux 上使用 Qt5 (C++)。如何检索程序将运行的系统的音频输入和输出设备名称?

【问题讨论】:

    标签: c++ linux qt audio


    【解决方案1】:

    这是一个受QAudioDeviceInfo 文档中示例启发的示例:

    #include <QtMultimedia/qaudiodeviceinfo.h>
    
    #include <iostream>
    
    int main() {
        // fetch info about all output devices
        const auto deviceInfos = QAudioDeviceInfo::availableDevices(QAudio::AudioOutput);
    
        // display the audio output devices names
        for(const QAudioDeviceInfo& deviceInfo : deviceInfos)
            std::cout << "Device name: " << deviceInfo.deviceName().toStdString() << '\n';
    }
    

    编译:

    -fPIC $(pkg-config --cflags --libs Qt5Multimedia)
    

    -fPIC 在您的系统上可能不是必需的。这取决于 Qt 库的编译方式)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-09-03
      • 2011-08-13
      • 2017-03-05
      • 1970-01-01
      • 1970-01-01
      • 2020-05-05
      • 1970-01-01
      相关资源
      最近更新 更多