简体   繁体   English

如何在 Linux 系统中检索音频输入和 output 设备名称?

[英]How to retrieve the audio input and output device names in a Linux system?

I am working with Qt5 (C++) on Debian Linux.我正在 Debian Linux 上使用 Qt5 (C++)。 How can I retrieve the audio input and output device names of the system the program will run?如何检索程序将运行的系统的音频输入和 output 设备名称?

Here's an example inspired by the example in the documentation for QAudioDeviceInfo :这是一个受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';
}

Compiled with:编译:

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

( -fPIC may not be necessary on your system. It depends on how the Qt libs were compiled) (您的系统上可能不需要-fPIC 。这取决于 Qt 库的编译方式)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM