我相信您可以使用多种工具来完成此操作,例如amixer
、 或pamd
、 或pactl
。
注意:你的假设也是我理解事物的方式。接收器我相当于实际的声卡(输出),它们的输出称为端口。
本指南标题为PulseAudio under the hood 的实际定义:
下沉
接收器是一个输出设备。它是消耗样本的活动单元。
Sink 通常运行一个具有自己的事件循环的线程,从连接的接收器输入中查看样本块,然后混合它们。它还实现时钟并保持延迟。世界其他地方通常使用消息与接收器进行通信。
典型的接收器代表输出声音设备,例如连接到声卡线路输出或蓝牙耳机上的耳机。PulseAudio 自动为每个检测到的输出设备创建一个接收器。
这是一个展示如何使用的示例pactl
:
$ pactl list sinks |& grep -E "Sink|Ports|analog-ou"
Sink #0
Ports:
analog-output-lineout: Line Out (priority: 9900, not available)
analog-output-headphones: Headphones (priority: 9000, not available)
Active Port: analog-output-lineout
Run Code Online (Sandbox Code Playgroud)
在上面您可以看到我Active Port:
当前的声卡线路输出。让我们把它换成耳机。
$ pactl set-sink-port 0 analog-output-headphones
Run Code Online (Sandbox Code Playgroud)
如果我们再次检查:
$ pactl list sinks |& grep -E "Sink|Ports|analog-ou"
X11 connection rejected because of wrong authentication.
Sink #0
Ports:
analog-output-lineout: Line Out (priority: 9900, not available)
analog-output-headphones: Headphones (priority: 9000, not available)
Active Port: analog-output-headphones
Run Code Online (Sandbox Code Playgroud)
从man pactl
:
set-sink-port SINK PORT
Set the specified sink (identified by its symbolic name or
numerical index) to the specified port (identified by its symbolic
name).
Run Code Online (Sandbox Code Playgroud)
在极少数情况下,我注意到音频输出设备从设备列表中神秘地消失。如果您发现发生这种情况,您可以通过告诉 Pulse Audio 重新加载其模块来轻松解决此问题:
$ pactl load-module module-detect
Run Code Online (Sandbox Code Playgroud)