Pulseaudio service

PulseAudio is the mainstream audio service system in the Linux environment. It lies between applications and the underlying audio architecture (TinyALSA), responsible for managing audio streams, mixing multi-channel audio, and routing it to different output devices.

PulseAudio Overview

PulseAudio is a cross-platform audio service that can work over a network. It receives audio input from one or more sources (processes or input devices), and then redirects the audio to one or more slots (sound cards, remote network PulseAudio services, or other processes). It interacts with the lowest-level ALSA (Advanced Linux Sound Architechture) and provides a unified interface for applications, thereby enabling advanced functions such as multi-channel audio mixing and audio forwarding.

View sound card information

  • Enter the following command in the terminal to check the mounting status of the sound card.
root@qcm6490-idp:/opt# cat /proc/asound/cards
 0 [qcm6490idpsndca]: qcm6490 - qcm6490-idp-snd-card
                      qcm6490-idp-snd-card

Equipment Inspection and Management

Check available output devices (Sinks)

To view the currently available audio output devices and their detailed information in the system, you can use the following command:
This command will list the indices and names of all available sinks (output devices). Sample output:

root@qcm6490-idp:/# pactl list short sinks
0       low-latency0    module-pal-card.c       s16le 1ch 16000Hz       SUSPENDED
1       deep-buffer0    module-pal-card.c       s16le 2ch 48000Hz       SUSPENDED
2       offload0        module-pal-card.c       s16le 2ch 48000Hz       SUSPENDED
3       voip-rx0        module-pal-card.c       s16le 2ch 48000Hz       SUSPENDED

Among them, the * symbol indicates the currently default output device.
To obtain more detailed device information, please use:

root@qcm6490-idp:/# pactl list sinks
Sink #0
        State: SUSPENDED
        Name: low-latency0
        Description: pal sink to play via low-latency path
        Driver: module-pal-card.c
        Sample Specification: s16le 1ch 16000Hz
        Channel Map: mono
        Owner Module: 1
        Mute: no
        Volume: mono: 65536 / 100%
                balance 0.00
        Base Volume: 65536 / 100%
        Monitor Source: low-latency0.monitor
        Latency: 0 usec, configured 0 usec
        Flags: HARDWARE HW_VOLUME_CTRL LATENCY
        Properties:
                device.string = "low_latency"
                device.description = "pal sink to play via low-latency path"
                device.icon_name = "audio-card"
        Ports:
                speaker: speaker (type: Unknown, priority: 200, available)
                headset: headset (type: Unknown, priority: 100, available)
        Active Port: speaker
        Formats:
                pcm

Sink #1
        State: SUSPENDED
        Name: deep-buffer0
        Description: pal sink to play via deep buffer path
        Driver: module-pal-card.c
        Sample Specification: s16le 2ch 48000Hz
        Channel Map: front-left,front-right
        Owner Module: 1
        Mute: no
        Volume: front-left: 65536 / 100%,   front-right: 65536 / 100%
                balance 0.00
        Base Volume: 65536 / 100%
        Monitor Source: deep-buffer0.monitor
        Latency: 0 usec, configured 0 usec
        Flags: HARDWARE HW_VOLUME_CTRL LATENCY
        Properties:
                device.string = "deep_buffer"
                device.description = "pal sink to play via deep buffer path"
                device.icon_name = "audio-card"
        Ports:
                speaker: speaker (type: Unknown, priority: 200, available)
                headset: headset (type: Unknown, priority: 100, available)
                bta2dp-out: BT a2dp source port (type: Unknown, priority: 50, not available)
        Active Port: speaker
        Formats:
                pcm

Sink #2
        State: SUSPENDED
        Name: offload0
        Description: pal sink to play compressed via offload path
        Driver: module-pal-card.c
        Sample Specification: s16le 2ch 48000Hz
        Channel Map: front-left,front-right
        Owner Module: 1
        Mute: no
        Volume: front-left: 65536 / 100%,   front-right: 65536 / 100%
                balance 0.00
        Base Volume: 65536 / 100%
        Monitor Source: offload0.monitor
        Latency: 0 usec, configured 0 usec
        Flags: HARDWARE HW_VOLUME_CTRL LATENCY
        Properties:
                device.string = "offload"
                device.description = "pal sink to play compressed via offload path"
                device.icon_name = "audio-card"
        Ports:
                speaker: speaker (type: Unknown, priority: 200, available)
                headset: headset (type: Unknown, priority: 100, available)
                bta2dp-out: BT a2dp source port (type: Unknown, priority: 50, not available)
        Active Port: speaker
        Formats:
                mpeg
                aac

Sink #3
        State: SUSPENDED
        Name: voip-rx0
        Description: pal sink to play via voip rx path
        Driver: module-pal-card.c
        Sample Specification: s16le 2ch 48000Hz
        Channel Map: front-left,front-right
        Owner Module: 1
        Mute: no
        Volume: front-left: 65536 / 100%,   front-right: 65536 / 100%
                balance 0.00
        Base Volume: 65536 / 100%
        Monitor Source: voip-rx0.monitor
        Latency: 0 usec, configured 0 usec
        Flags: HARDWARE HW_VOLUME_CTRL LATENCY
        Properties:
                device.string = "voip_rx"
                device.description = "pal sink to play via voip rx path"
                device.icon_name = "audio-card"
        Ports:
                speaker: speaker (type: Unknown, priority: 200, available)
                headset: headset (type: Unknown, priority: 100, available)
                btsco-out: BT SCO sink port (type: Unknown, priority: 50, not available)
        Active Port: speaker
        Formats:
                pcm

View Input Devices (Sources)

Similarly, you can check the audio input device (such as a microphone):

root@qcm6490-idp:/# pactl list short sources
0       low-latency0.monitor    module-pal-card.c       s16le 1ch 16000Hz       SUSPENDED
1       deep-buffer0.monitor    module-pal-card.c       s16le 2ch 48000Hz       SUSPENDED
2       offload0.monitor        module-pal-card.c       s16le 2ch 48000Hz       SUSPENDED
3       voip-rx0.monitor        module-pal-card.c       s16le 2ch 48000Hz       SUSPENDED
4       regular0        module-pal-card.c       s16le 2ch 48000Hz       SUSPENDED
5       regular2        module-pal-card.c       s16le 2ch 48000Hz       SUSPENDED
6       voip-tx0        module-pal-card.c       s16le 1ch 48000Hz       SUSPENDED

Record

Built-in DIMC recording

root@qcm6490-idp:~# pactl set-source-port 5 speaker-mic
root@qcm6490-idp:~# parec -d 5 --file-format=wav output.wav

3.5mm headphone recording

Before recording with 3.5mm headphones, it is necessary to set the levels of gpio8 and gpio68 to high.

root@qcm6490-idp:/opt# rgpiod &
root@qcm6490-idp:/opt# sleep 1
root@qcm6490-idp:/opt# rgs c 999 go 4
root@qcm6490-idp:/opt# rgs c 999 gso 0 8
root@qcm6490-idp:/opt# rgs c 999 gw 0 8 1
root@qcm6490-idp:/opt# rgs c 999 gso 0 68
root@qcm6490-idp:/opt# rgs c 999 gw 0 68 1
  • gpio8------------Headphone standard conversion control switch, set 0: European standard, set 1: American standard
  • gpio68-----------Headphone power supply enable switch: 0 means disable, 1 means enable
root@qcm6490-idp:~# pactl set-source-port 5 headset-mic
root@qcm6490-idp:~# parec -d 5 --file-format=wav output1.wav

Playback

loudspeaker playback

// GPIO controls the enable switch of PA

rgpiod &
sleep 1
rgs c 999 go 4
rgs c 999 gso 0 142
rgs c 999 gw 0 142 1
root@qcm6490-idp:~# pactl set-sink-port 0 speaker
root@qcm6490-idp:~# paplay output.wav

3.5mm headset playback

root@qcm6490-idp:~# pactl set-sink-port 0 headset
root@qcm6490-idp:~# paplay output1.wav