pulseaudio-点点滴滴

Posted huangkj-henan

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了pulseaudio-点点滴滴相关的知识,希望对你有一定的参考价值。

pulseaudio点点滴滴

Pulseaudio命令

pulseaudio

  • pulseaudio -h
root@2012000099:~# pulseaudio -h
pulseaudio [options]

COMMANDS:
  -h, --help                            Show this help
      --version                         Show version
      --dump-conf                       Dump default configuration
      --dump-modules                    Dump list of available modules
      --dump-resample-methods           Dump available resample methods
      --cleanup-shm                     Cleanup stale shared memory segments
      --start                           Start the daemon if it is not running
  -k  --kill                            Kill a running daemon
      --check                           Check for a running daemon (only returns                                                                                                                                                                                                                                  exit code)

OPTIONS:
      --system[=BOOL]                   Run as system-wide instance
  -D, --daemonize[=BOOL]                Daemonize after startup
      --fail[=BOOL]                     Quit when startup fails
      --high-priority[=BOOL]            Try to set high nice level
                                        (only available as root, when SUID or
                                        with elevated RLIMIT_NICE)
      --realtime[=BOOL]                 Try to enable realtime scheduling
                                        (only available as root, when SUID or
                                        with elevated RLIMIT_RTPRIO)
      --disallow-module-loading[=BOOL]  Disallow module user requested module
                                        loading/unloading after startup
      --disallow-exit[=BOOL]            Disallow user requested exit
      --exit-idle-time=SECS             Terminate the daemon when idle and this
                                        time passed
      --scache-idle-time=SECS           Unload autoloaded samples when idle and
                                        this time passed
      --log-level[=LEVEL]               Increase or set verbosity level
  -v  --verbose                         Increase the verbosity level
      --log-target=auto,syslog,stderr,file:PATH,newfile:PATH
                                        Specify the log target
      --log-meta[=BOOL]                 Include code location in log messages
      --log-time[=BOOL]                 Include timestamps in log messages
      --log-backtrace=FRAMES            Include a backtrace in log messages
  -p, --dl-search-path=PATH             Set the search path for dynamic shared
                                        objects (plugins)
      --resample-method=METHOD          Use the specified resampling method
                                        (See --dump-resample-methods for
                                        possible values)
      --use-pid-file[=BOOL]             Create a PID file
      --no-cpu-limit[=BOOL]             Do not install CPU load limiter on
                                        platforms that support it.
      --disable-shm[=BOOL]              Disable shared memory support.

STARTUP SCRIPT:
  -L, --load="MODULE ARGUMENTS"         Load the specified plugin module with
                                        the specified argument
  -F, --file=FILENAME                   Run the specified script
  -C                                    Open a command line on the running TTY
                                        after startup

  -n                                    Don't load default script file

  • pulseaudio --dump-resample-methods
root@2012000099:~# pulseaudio --dump-resample-methods
trivial
speex-float-0
speex-float-1
speex-float-2
speex-float-3
speex-float-4
speex-float-5
speex-float-6
speex-float-7
speex-float-8
speex-float-9
speex-float-10
speex-fixed-0
speex-fixed-1
speex-fixed-2
speex-fixed-3
speex-fixed-4
speex-fixed-5
speex-fixed-6
speex-fixed-7
speex-fixed-8
speex-fixed-9
speex-fixed-10
ffmpeg
auto
copy
peaks

pacmd

pactl

  • pactl -h
root@2012000099:~# pactl -h
]pactl [options] stat
pactl [options] info
pactl [options] list [short] [TYPE]
pactl [options] exit
pactl [options] upload-sample FILENAME [NAME]
pactl [options] play-sample  NAME [SINK]
pactl [options] remove-sample  NAME
pactl [options] load-module  NAME [ARGS ...]
pactl [options] unload-module  NAME|#N
pactl [options] move-(sink-input|source-output) #N SINK|SOURCE
pactl [options] suspend-(sink|source) NAME|#N 1|0
pactl [options] set-card-profile  CARD PROFILE
pactl [options] set-default-(sink|source) NAME
pactl [options] set-(sink|source)-port NAME|#N PORT
pactl [options] set-(sink|source)-volume NAME|#N VOLUME [VOLUME ...]
pactl [options] set-(sink-input|source-output)-volume #N VOLUME [VOLUME ...]
pactl [options] set-(sink|source)-mute NAME|#N 1|0|toggle
pactl [options] set-(sink-input|source-output)-mute #N 1|0|toggle
pactl [options] set-sink-formats #N FORMATS
pactl [options] set-port-latency-offset CARD-NAME|CARD-#N PORT OFFSET
pactl [options] subscribe

The special names @DEFAULT_SINK@, @DEFAULT_SOURCE@ and @DEFAULT_MONITOR@
can be used to specify the default sink, source and monitor.

  -h, --help                            Show this help
      --version                         Show version

  -s, --server=SERVER                   The name of the server to connect to
  -n, --client-name=NAME                How to call this client on the server

  • pactl list
root@2012000099:~# pactl list
Module #1
        Name: module-alsa-sink
        Argument: device_id=0
        Usage counter: 1
        Properties:
                module.author = "Lennart Poettering"
                module.description = "ALSA Sink"
                module.version = "6.0-dirty"

Module #2
        Name: module-alsa-source
        Argument: device_id=0
        Usage counter: 1
        Properties:
                module.author = "Lennart Poettering"
                module.description = "ALSA Source"
                module.version = "6.0-dirty"

Module #3
        Name: module-esound-protocol-unix
        Argument:
        Usage counter: n/a
        Properties:
                module.author = "Lennart Poettering"
                module.description = "ESOUND protocol (UNIX sockets)"
                module.version = "6.0-dirty"

Module #4
        Name: module-native-protocol-unix
        Argument:
        Usage counter: n/a
        Properties:
                module.author = "Lennart Poettering"
                module.description = "Native protocol (UNIX sockets)"
                module.version = "6.0-dirty"

Module #5
        Name: module-stream-restore
        Argument:
        Usage counter: n/a
        Properties:
                module.author = "Lennart Poettering"
                module.description = "Automatically restore the volume/mute/device state of streams"
                module.version = "6.0-dirty"

Module #6
        Name: module-device-restore
        Argument:
        Usage counter: n/a
        Properties:
                module.author = "Lennart Poettering"
                module.description = "Automatically restore the volume/mute state of devices"
                module.version = "6.0-dirty"

Module #7
        Name: module-default-device-restore
        Argument:
        Usage counter: n/a
        Properties:
                module.author = "Lennart Poettering"
                module.description = "Automatically restore the default sink and source"
                module.version = "6.0-dirty"

Module #8
        Name: module-rescue-streams
        Argument:
        Usage counter: n/a
        Properties:
                module.author = "Lennart Poettering"
                module.description = "When a sink/source is removed, try to move its streams to the default sink/source"
                module.version = "6.0-dirty"

Module #9
        Name: module-always-sink
        Argument:
        Usage counter: n/a
        Properties:
                module.author = "Colin Guthrie"
                module.description = "Always keeps at least one sink loaded even if it's a null one"
                module.version = "6.0-dirty"

Module #10
        Name: module-suspend-on-idle
        Argument:
        Usage counter: n/a
        Properties:
                module.author = "Lennart Poettering"
                module.description = "When a sink/source is idle for too long, suspend it"
                module.version = "6.0-dirty"

Module #11
        Name: module-position-event-sounds
        Argument:
        Usage counter: n/a
        Properties:
                module.author = "Lennart Poettering"
                module.description = "Position event sounds between L and R depending on the position on screen of the widget triggering them."
                module.version = "6.0-dirty"

Sink #0
        State: SUSPENDED
        Name: alsa_output.0.analog-stereo
        Description: MTK APSoC I2S Analog Stereo
        Driver: module-alsa-sink.c
        Sample Specification: s16le 2ch 48000Hz
        Channel Map: front-left,front-right
        Owner Module: 1
        Mute: no
        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
        Monitor Source: alsa_output.0.analog-stereo.monitor
        Latency: 0 usec, configured 0 usec
        Flags: HARDWARE DECIBEL_VOLUME LATENCY
        Properties:
                alsa.resolution_bits = "16"
                device.api = "alsa"
                device.class = "sound"
                alsa.class = "generic"
                alsa.subclass = "generic-mix"
                alsa.name = ""
                alsa.id = "WMserious PCM wm8960-hifi-0"
                alsa.subdevice = "0"
                alsa.subdevice_name = "subdevice #0"
                alsa.device = "0"
                alsa.card = "0"
                alsa.card_name = "MTK APSoC I2S"
                alsa.long_card_name = "MTK APSoC I2S"
                alsa.driver_name = "snd_soc_core"
                device.string = "hw:0"
                device.buffering.buffer_size = "49152"
                device.buffering.fragment_size = "6144"
                device.access_mode = "mmap+timer"
                device.profile.name = "analog-stereo"
                device.profile.description = "Analog Stereo"
                device.description = "MTK APSoC I2S Analog Stereo"
                device.icon_name = "audio-card-analog"
        Formats:
                pcm

Source #0
        State: SUSPENDED
        Name: alsa_output.0.analog-stereo.monitor
        Description: Monitor of MTK APSoC I2S Analog Stereo
        Driver: module-alsa-sink.c
        Sample Specification: s16le 2ch 48000Hz
        Channel Map: front-left,front-right
        Owner Module: 1
        Mute: no
        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
        Monitor of Sink: alsa_output.0.analog-stereo
        Latency: 0 usec, configured 0 usec
        Flags: DECIBEL_VOLUME LATENCY
        Properties:
                device.description = "Monitor of MTK APSoC I2S Analog Stereo"
                device.class = "monitor"
                device.icon_name = "audio-input-microphone"
        Formats:
                pcm

Source #1
        State: RUNNING
        Name: alsa_input.0.analog-stereo
        Description: MTK APSoC I2S Analog Stereo
        Driver: module-alsa-source.c
        Sample Specification: s16le 2ch 44100Hz
        Channel Map: front-left,front-right
        Owner Module: 2
        Mute: no
        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
        Monitor of Sink: n/a
        Latency: 15820 usec, configured 106000 usec
        Flags: HARDWARE DECIBEL_VOLUME LATENCY
        Properties:
                alsa.resolution_bits = "16"
                device.api = "alsa"
                device.class = "sound"
                alsa.class = "generic"
                alsa.subclass = "generic-mix"
                alsa.name = ""
                alsa.id = "WMserious PCM wm8960-hifi-0"
                alsa.subdevice = "0"
                alsa.subdevice_name = "subdevice #0"
                alsa.device = "0"
                alsa.card = "0"
                alsa.card_name = "MTK APSoC I2S"
                alsa.long_card_name = "MTK APSoC I2S"
                alsa.driver_name = "snd_soc_core"
                device.string = "hw:0"
                device.buffering.buffer_size = "49152"
                device.buffering.fragment_size = "6144"
                device.access_mode = "mmap+timer"
                device.profile.name = "analog-stereo"
                device.profile.description = "Analog Stereo"
                device.description = "MTK APSoC I2S Analog Stereo"
                device.icon_name = "audio-input-microphone-analog"
        Formats:
                pcm

Sink Input #1
        Driver: protocol-native.c
        Owner Module: 4
        Client: 3
        Sink: 0
        Sample Specification: s16le 1ch 8000Hz
        Channel Map: mono
        Format: pcm, format.sample_format = "\\"s16le\\""  format.rate = "8000"  format.channels = "1"  format.channel_map = "\\"mono\\""
        Corked: no
        Mute: no
        Volume: mono: 65536 / 100% / 0.00 dB
                balance 0.00
        Buffer Latency: 0 usec
        Sink Latency: 0 usec
        Resample method: speex-fixed-1
        Properties:
                media.name = "ALSA Playback"
                application.name = "ALSA plug-in [asterisk]"
                native-protocol.peer = "UNIX socket client"
                native-protocol.version = "30"
                application.process.id = "2183"
                application.process.user = "root"
                application.process.host = "2012000099"
                application.process.binary = "asterisk"
                application.language = "C"
                application.process.machine_id = "2012000099"
                module-stream-restore.id = "sink-input-by-application-name:ALSA plug-in [asterisk]"

Source Output #1
        Driver: protocol-native.c
        Owner Module: 4
        Client: 2
        Source: 1
        Sample Specification: s16le 1ch 8000Hz
        Channel Map: mono
        Format: pcm, format.sample_format = "\\"s16le\\""  format.rate = "8000"  format.channels = "1"  format.channel_map = "\\"mono\\""
        Corked: no
        Mute: no
        Volume: mono: 65536 / 100% / 0.00 dB
                balance 0.00
        Buffer Latency: 0 usec
        Source Latency: 17603 usec
        Resample method: speex-fixed-1
        Properties:
                media.name = "ALSA Capture"
                application.name = "ALSA plug-in [asterisk]"
                native-protocol.peer = "UNIX socket client"
                native-protocol.version = "30"
                application.process.id = "2183"
                application.process.user = "root"
                application.process.host = "2012000099"
                application.process.binary = "asterisk"
                application.language = "C"
                application.process.machine_id = "2012000099"
                module-stream-restore.id = "source-output-by-application-name:ALSA plug-in [asterisk]"

Client #2
        Driver: protocol-native.c
        Owner Module: 4
        Properties:
                application.name = "ALSA plug-in [asterisk]"
                native-protocol.peer = "UNIX socket client"
                native-protocol.version = "30"
                application.process.id = "2183"
                application.process.user = "root"
                application.process.host = "2012000099"
                application.process.binary = "asterisk"
                application.language = "C"
                application.process.machine_id = "2012000099"

Client #3
        Driver: protocol-native.c
        Owner Module: 4
        Properties:
                application.name = "ALSA plug-in [asterisk]"
                native-protocol.peer = "UNIX socket client"
                native-protocol.version = "30"
                application.process.id = "2183"
                application.process.user = "root"
                application.process.host = "2012000099"
                application.process.binary = "asterisk"
                application.language = "C"
                application.process.machine_id = "2012000099"

Client #6
        Driver: protocol-native.c
        Owner Module: 4
        Properties:
                application.name = "pactl"
                native-protocol.peer = "UNIX socket client"
                native-protocol.version = "30"
                application.process.id = "20264"
                application.process.user = "root"
                application.process.host = "2012000099"
                application.process.binary = "pactl"
                application.language = "C"
                application.process.machine_id = "2012000099"

parecord

paplay

root@2012000099:~# paplay -h
paplay [options]

  -h, --help                            Show this help
      --version                         Show version

  -r, --record                          Create a connection for recording
  -p, --playback                        Create a connection for playback

  -v, --verbose                         Enable verbose operations

  -s, --server=SERVER                   The name of the server to connect to
  -d, --device=DEVICE                   The name of the sink/source to connect to
  -n, --client-name=NAME                How to call this client on the server
      --stream-name=NAME                How to call this stream on the server
      --volume=VOLUME                   Specify the initial (linear) volume in range 0...65536
      --rate=SAMPLERATE                 The sample rate in Hz (defaults to 44100)
      --format=SAMPLEFORMAT             The sample type, one of s16le, s16be, u8, float32le,
                                        float32be, ulaw, alaw, s32le, s32be, s24le, s24be,
                                        s24-32le, s24-32be (defaults to s16ne)
      --channels=CHANNELS               The number of channels, 1 for mono, 2 for stereo
                                        (defaults to 2)
      --channel-map=CHANNELMAP          Channel map to use instead of the default
      --fix-format                      Take the sample format from the sink/source the stream is
                                        being connected to.
      --fix-rate                        Take the sampling rate from the sink/source the stream is
                                        being connected to.
      --fix-channels                    Take the number of channels and the channel map
                                        from the sink/source the stream is being connected to.
      --no-remix                        Don't upmix or downmix channels.
      --no-remap                        Map channels by index instead of name.
      --latency=BYTES                   Request the specified latency in bytes.
      --process-time=BYTES              Request the specified process time per request in bytes.
      --latency-msec=MSEC               Request the specified latency in msec.
      --process-time-msec=MSEC          Request the specified process time per request in msec.
      --property=PROPERTY=VALUE         Set the specified property to the specified value.
      --raw                             Record/play raw PCM data.
      --passthrough                     Passthrough data.
      --file-format[=FFORMAT]           Record/play formatted PCM data.
      --list-file-formats               List available file formats.
      --monitor-stream=INDEX            Record from the sink input with index INDEX.
```

#### parecord

```
root@2012000099:~# parecord -h
parecord [options]

  -h, --help                            Show this help
      --version                         Show version

  -r, --record                          Create a connection for recording
  -p, --playback                        Create a connection for playback

  -v, --verbose                         Enable verbose operations

  -s, --server=SERVER                   The name of the server to connect to
  -d, --device=DEVICE                   The name of the sink/source to connect to
  -n, --client-name=NAME                How to call this client on the server
      --stream-name=NAME                How to call this stream on the server
      --volume=VOLUME                   Specify the initial (linear) volume in range 0...65536
      --rate=SAMPLERATE                 The sample rate in Hz (defaults to 44100)
      --format=SAMPLEFORMAT             The sample type, one of s16le, s16be, u8, float32le,
                                        float32be, ulaw, alaw, s32le, s32be, s24le, s24be,
                                        s24-32le, s24-32be (defaults to s16ne)
      --channels=CHANNELS               The number of channels, 1 for mono, 2 for stereo
                                        (defaults to 2)
      --channel-map=CHANNELMAP          Channel map to use instead of the default
      --fix-format                      Take the sample format from the sink/source the stream is
                                        being connected to.
      --fix-rate                        Take the sampling rate from the sink/source the stream is
                                        being connected to.
      --fix-channels                    Take the number of channels and the channel map
                                        from the sink/source the stream is being connected to.
      --no-remix                        Don't upmix or downmix channels.
      --no-remap                        Map channels by index instead of name.
      --latency=BYTES                   Request the specified latency in bytes.
      --process-time=BYTES              Request the specified process time per request in bytes.
      --latency-msec=MSEC               Request the specified latency in msec.
      --process-time-msec=MSEC          Request the specified process time per request in msec.
      --property=PROPERTY=VALUE         Set the specified property to the specified value.
      --raw                             Record/play raw PCM data.
      --passthrough                     Passthrough data.
      --file-format[=FFORMAT]           Record/play formatted PCM data.
      --list-file-formats               List available file formats.
      --monitor-stream=INDEX            Record from the sink input with index INDEX.
```

## 参考文档

<https://www.freedesktop.org/wiki/Software/PulseAudio/FAQ/>

以上是关于pulseaudio-点点滴滴的主要内容,如果未能解决你的问题,请参考以下文章

pulseaudio-点点滴滴

yocto 中的 Pulseaudio 构建问题

奇怪的 PulseAudio 监控设备行为

ALSA 与 PulseAudio - 延迟问题

注意 ALSA/Pulseaudio 中的音量变化

在 Ubuntu 上通过 PulseAudio 从 Java 播放音频文件时出错