如何使用pacmd來選擇輸出的設備
(由HDMI輸出或LineOut輸出)
更新記錄
item | note |
---|---|
20170222 | 第一版: 如何設定輸出設備 |
目錄
如何設定輸出設備
Set the default output source
先使用pacmd list-sinks-inputs,找出有那些sink index
再使用pacmd set-default-sink 0 或 pacmd set-default-sink 名稱(name)1
2pacmd set-default-sink 0
pacmd set-default-sink alsa_output.pci-0000_00_1f.3.iec958-stereopacmd list-sinks-inputs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
301 sink input(s) available.
index: 0
driver: <protocol-native.c>
flags:
state: DRAINED
sink: 0 <alsa_output.pci-0000_00_1f.3.iec958-stereo>
volume: mono: 65536 / 100% / 0.00 dB
balance 0.00
muted: no
current latency: 0.00 ms
requested latency: 125.00 ms
sample spec: s16le 1ch 8000Hz
channel map: mono
Mono
resample method: speex-float-1
module: 11
client: 0 <ALSA plug-in [nvr]>
properties:
media.name = "ALSA Playback"
application.name = "ALSA plug-in [nvr]"
native-protocol.peer = "UNIX socket client"
native-protocol.version = "30"
application.process.id = "823"
application.process.user = "root"
application.process.host = "localhost.localdomain"
application.process.binary = "nvr"
application.language = "en_US.UTF-8"
window.x11.display = ":0"
application.process.machine_id = "591ae69f060143d296b3ab64faea41e1"
module-stream-restore.id = "sink-input-by-application-name:ALSA plug-in [nvr]"
Pulseaudio
- What Is PulseAudio?
PulseAudio is a sound system for POSIX OSes, meaning that it is a proxy for your sound applications.
來源:PulseAudio
pulseaudio為一個audio service
OSS sink表示輸出音源部分
從PulseAudio要轉到聲音設備的介面OSS source表示輸入音源部分
任何需要進入到PulseAudio的聲音,都會經由source介面
- PulseAudio服務軟體
- 將來自各個不同的音源轉到正確的窗口
- 針對不同的應用程式做音量的調整
- 接受多個音源的輸入(source)或是輸出(sink)
command
pactl可以修改伺服器的設定以及配置,但pactl僅限於侷限的範圍
若要完整的功能,就必須要回歸到最基本的指令pacmd,透過pacmd指令
才可以完全的控制PulseAudio的服務核心。
- 於fedora24提供下例指令
- pulseaudio - The PulseAudio Sound System
- pactl - Control a running PulseAudio sound server
- pacmd - Reconfigure a PulseAudio sound server during runtime
pactl info
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15Server String: /tmp/pulse-9S2nAsoQttCY/native
Library Protocol Version: 30
Server Protocol Version: 30
Is Local: yes
Client Index: 8
Tile Size: 65472
User Name: root
Host Name: localhost.localdomain
Server Name: pulseaudio
Server Version: 8.0
Default Sample Specification: s16le 2ch 44100Hz
Default Channel Map: front-left,front-right
Default Sink: alsa_output.pci-0000_00_1f.3.iec958-stereo
Default Source: alsa_input.pci-0000_00_1f.3.analog-stereo
Cookie: fca1:256cpactl list
查看週邊,可知目前只有1個source1
2
3
4
5
6
7
8
9
10
11
12Sink #0
State: RUNNING
Name: alsa_output.pci-0000_00_1f.3.iec958-stereo
Description: Built-in Audio Digital Stereo (IEC958)
Driver: module-alsa-card.c
Sample Specification: s16le 2ch 48000Hz
Channel Map: front-left,front-right
Owner Module: 6
Mute: yes
Volume: front-left: 65536 / 100% / 0.00 dB, front-right: 65536 / 100% / 0.00 dB
balance 0.00
Base Volume: 65536 / 100% / 0.00 dB
ALSA
來源:PulseAudio
- ALSA: Advanced Linux Sound Architecture
1個聲音的組織,主要是希望所有聲音相關的設備廠商可以遵循一樣的標準之前比較有名的是OSS,現在大部分都被ALSA取代
在Linux的世界中,要聲音的硬體可以正常播放,最重要的元件大概就是ALSA,因為一般硬體的驅動程式或是一些聲音相關的函式庫,都是由ALSA所提供