问题
我正在使用pulseaudio 将一台小型Linux 计算机(CHIP)设置为蓝牙接收器。该设备是无头的,所以我想获得一个在启动时工作的配置。一切都很好,除了当我的手机连接到 CHIP 时,某些东西总是将其接收音量设置为 0%。
当pulseaudio 设置接收器输入时,如何让 Pulse/ALSA 不影响主音量?或者也许是脉搏造成的——我不确定。
我尝试过的事情
module-*-restore
从pulsaudio 中删除。- 将平卷设置为 no
alsactl store
- 添加指令
system.pa
和/或default.pa
使pulseaudio将该接收器的音量设置为100%
如果我在手机连接时运行 alsamixer,我会看到音量从 100% 变为 0%,日志行如下:
D: [pulseaudio] protocol-native.c: Client amixer changes volume of sink alsa_output.platform-1c22c00.codec.analog-stereo.
设置的
- Bluez 宣传为媒体/接收器设备
- Pulseaudio 作为系统实例运行(是的,我知道为什么这很糟糕)
- 它监视 bluez 的连接
- 当我的手机连接 PA 时,会设置一个环回接收器输入到 ALSA 接收器
- ALSA 立即将音量设置为 0%。有时候是这样的每次我的手机通过蓝牙连接
我所要做的就是运行 alsamixer 并将主音量设置为 100%。
更多信息
以下是我发给 pulseaudio-discuss 的信息(截至撰写本文时回复为零)。
附近的调试日志行:
I: [pulseaudio] client.c: Created 26 "Native client (UNIX socket client)"
I: [pulseaudio] protocol-native.c: Client authenticated anonymously.
D: [pulseaudio] protocol-native.c: Protocol version: remote 29, local 29
D: [pulseaudio] protocol-native.c: SHM possible: no
D: [pulseaudio] protocol-native.c: Negotiated SHM: no
D: [pulseaudio] protocol-native.c: Client amixer changes volume of sink alsa_output.platform-1c22c00.codec.analog-stereo.
D: [alsa-sink-CDC PCM Codec-0] alsa-sink.c: Requested to rewind 524288 bytes.
D: [alsa-sink-CDC PCM Codec-0] alsa-sink.c: Limited to 18200 bytes.
D: [alsa-sink-CDC PCM Codec-0] alsa-sink.c: before: 2275
D: [alsa-sink-CDC PCM Codec-0] alsa-sink.c: after: 2275
D: [alsa-sink-CDC PCM Codec-0] alsa-sink.c: Rewound 18200 bytes.
D: [alsa-sink-CDC PCM Codec-0] sink.c: Processing rewind...
D: [alsa-sink-CDC PCM Codec-0] sink-input.c: Have to rewind 18200 bytes on render memblockq.
D: [alsa-sink-CDC PCM Codec-0] source.c: Processing rewind...
I: [pulseaudio] module-device-restore.c: Storing volume/mute for device+port sink:alsa_output.platform-1c22c00.codec.analog-stereo:analog-output.
I: [pulseaudio] client.c: Freed 26 "ALSA plug-in [amixer]"
I: [pulseaudio] protocol-native.c: Connection died.
全连接调试。
D: [pulseaudio] bluez5-util.c: Properties changed in device /org/bluez/hci0/dev_1C_56_FE_9D_1B_0E
D: [pulseaudio] bluez4-util.c: dbus: interface=org.freedesktop.DBus.Properties, path=/org/bluez/hci0/dev_1C_56_FE_9D_1B_0E, member=PropertiesChanged
D: [pulseaudio] bluez5-util.c: Unknown interface org.freedesktop.DBus.Introspectable found, skipping
D: [pulseaudio] bluez5-util.c: Unknown interface org.bluez.MediaTransport1 found, skipping
D: [pulseaudio] bluez5-util.c: Unknown interface org.freedesktop.DBus.Properties found, skipping
D: [pulseaudio] bluez4-util.c: dbus: interface=org.freedesktop.DBus.ObjectManager, path=/, member=InterfacesAdded
D: [pulseaudio] bluez4-util.c: dbus: interface=org.bluez.MediaEndpoint1, path=/MediaEndpoint/A2DPSink, member=SetConfiguration
D: [pulseaudio] bluez5-util.c: dbus: path=/MediaEndpoint/A2DPSink, interface=org.bluez.MediaEndpoint1, member=SetConfiguration
D: [pulseaudio] bluez5-util.c: Transport /org/bluez/hci0/dev_1C_56_FE_9D_1B_0E/fd11 state changed from disconnected to idle
D: [pulseaudio] module-bluez5-discover.c: Loading module-bluez5-device path=/org/bluez/hci0/dev_1C_56_FE_9D_1B_0E
I: [pulseaudio] card.c: Created 4 "bluez_card.1C_56_FE_9D_1B_0E"
D: [pulseaudio] module-bluez5-device.c: Acquiring transport /org/bluez/hci0/dev_1C_56_FE_9D_1B_0E/fd11
I: [pulseaudio] bluez5-util.c: Failed optional acquire of unavailable transport /org/bluez/hci0/dev_1C_56_FE_9D_1B_0E/fd11
I: [pulseaudio] module-bluez5-device.c: SBC parameters: allocation=0, subbands=1, blocks=3, bitpool=2
D: [pulseaudio] module-device-restore.c: Database contains invalid data for key: source:bluez_source.1C_56_FE_9D_1B_0E:null
I: [pulseaudio] source.c: Created source 5 "bluez_source.1C_56_FE_9D_1B_0E" with sample spec s16le 2ch 44100Hz and channel map front-left,front-right
I: [pulseaudio] source.c: bluetooth.protocol = "a2dp_source"
I: [pulseaudio] source.c: device.description = "MotoG3"
I: [pulseaudio] source.c: device.string = "1C:56:FE:9D:1B:0E"
I: [pulseaudio] source.c: device.api = "bluez"
I: [pulseaudio] source.c: device.class = "sound"
I: [pulseaudio] source.c: device.bus = "bluetooth"
I: [pulseaudio] source.c: device.form_factor = "phone"
I: [pulseaudio] source.c: bluez.path = "/org/bluez/hci0/dev_1C_56_FE_9D_1B_0E"
I: [pulseaudio] source.c: bluez.class = "0x5a020c"
I: [pulseaudio] source.c: bluez.alias = "MotoG3"
I: [pulseaudio] source.c: device.icon_name = "audio-card-bluetooth"
D: [bluetooth] module-bluez5-device.c: IO Thread starting up
D: [pulseaudio] module-suspend-on-idle.c: Source bluez_source.1C_56_FE_9D_1B_0E becomes idle, timeout in 5 seconds.
D: [pulseaudio] sink-input.c: Negotiated format: pcm, format.sample_format = "\"s16le\"" format.rate = "44100" format.channels = "2" format.channel_map = "\"front-left,front-right\""
D: [pulseaudio] module-suspend-on-idle.c: Sink alsa_output.platform-1c22c00.codec.analog-stereo becomes busy, resuming.
D: [pulseaudio] sink.c: Suspend cause of sink alsa_output.platform-1c22c00.codec.analog-stereo is 0x0000, resuming
I: [alsa-sink-CDC PCM Codec-0] alsa-sink.c: Trying resume...
I: [alsa-sink-CDC PCM Codec-0] alsa-util.c: cannot disable ALSA period wakeups
D: [alsa-sink-CDC PCM Codec-0] alsa-util.c: Maximum hw buffer size is 1489 ms
D: [alsa-sink-CDC PCM Codec-0] alsa-util.c: Set buffer size first (to 65536 samples), period size second (to 8192 samples).
I: [alsa-sink-CDC PCM Codec-0] alsa-util.c: ALSA period wakeups were not disabled
D: [alsa-sink-CDC PCM Codec-0] alsa-sink.c: hwbuf_unused=0
D: [alsa-sink-CDC PCM Codec-0] alsa-sink.c: setting avail_min=64656
I: [alsa-sink-CDC PCM Codec-0] alsa-sink.c: Time scheduling watermark is 20.00ms
I: [alsa-sink-CDC PCM Codec-0] alsa-sink.c: Resumed successfully...
D: [pulseaudio] module-suspend-on-idle.c: Sink alsa_output.platform-1c22c00.codec.analog-stereo becomes idle, timeout in 5 seconds.
I: [alsa-sink-CDC PCM Codec-0] alsa-sink.c: Starting playback.
D: [alsa-sink-CDC PCM Codec-0] alsa-sink.c: Cutting sleep time for the initial iterations by half.
D: [pulseaudio] module-suspend-on-idle.c: Sink alsa_output.platform-1c22c00.codec.analog-stereo becomes idle, timeout in 5 seconds.
I: [pulseaudio] resampler.c: Resampler 'ffmpeg' cannot do variable rate, reverting to resampler 'auto'.
D: [pulseaudio] resampler.c: Resampler:
D: [pulseaudio] resampler.c: rate 44100 -> 44000 (method speex-fixed-1)
D: [pulseaudio] resampler.c: format s16le -> s32le (intermediate s16le)
D: [pulseaudio] resampler.c: channels 2 -> 2 (resampling 2)
I: [pulseaudio] resampler.c: Choosing speex quality setting 1.
D: [pulseaudio] memblockq.c: memblockq requested: maxlength=33554432, tlength=0, base=8, prebuf=0, minreq=1 maxrewind=0
D: [pulseaudio] memblockq.c: memblockq sanitized: maxlength=33554432, tlength=33554432, base=8, prebuf=0, minreq=8 maxrewind=0
I: [pulseaudio] sink-input.c: Created input 3 "(null)" on alsa_output.platform-1c22c00.codec.analog-stereo with sample spec s16le 2ch 44100Hz and channel map front-left,front-right
I: [pulseaudio] sink-input.c: media.role = "music"
I: [pulseaudio] sink-input.c: module-stream-restore.id = "sink-input-by-media-role:music"
D: [alsa-sink-CDC PCM Codec-0] alsa-sink.c: Cutting sleep time for the initial iterations by half.
D: [pulseaudio] module-stream-restore.c: Not restoring device for stream source-output-by-media-role:abstract, because already set
D: [pulseaudio] source-output.c: Negotiated format: pcm, format.sample_format = "\"s16le\"" format.rate = "44100" format.channels = "2" format.channel_map = "\"front-left,front-right\""
D: [pulseaudio] module-suspend-on-idle.c: Source bluez_source.1C_56_FE_9D_1B_0E becomes busy, resuming.
D: [pulseaudio] module-suspend-on-idle.c: Source bluez_source.1C_56_FE_9D_1B_0E becomes idle, timeout in 5 seconds.
D: [pulseaudio] memblockq.c: memblockq requested: maxlength=33554432, tlength=0, base=4, prebuf=0, minreq=1 maxrewind=0
D: [pulseaudio] memblockq.c: memblockq sanitized: maxlength=33554432, tlength=33554432, base=4, prebuf=0, minreq=4 maxrewind=0
I: [pulseaudio] source-output.c: Created output 3 "(null)" on bluez_source.1C_56_FE_9D_1B_0E with sample spec s16le 2ch 44100Hz and channel map front-left,front-right
I: [pulseaudio] source-output.c: media.role = "abstract"
I: [pulseaudio] source-output.c: module-stream-restore.id = "source-output-by-media-role:abstract"
D: [alsa-sink-CDC PCM Codec-0] alsa-sink.c: Cutting sleep time for the initial iterations by half.
D: [pulseaudio] memblockq.c: memblockq requested: maxlength=16777216, tlength=16777216, base=4, prebuf=0, minreq=0 maxrewind=0
D: [pulseaudio] memblockq.c: memblockq sanitized: maxlength=16777216, tlength=16777216, base=4, prebuf=0, minreq=4 maxrewind=0
D: [alsa-sink-CDC PCM Codec-0] alsa-sink.c: Cutting sleep time for the initial iterations by half.
D: [alsa-sink-CDC PCM Codec-0] alsa-sink.c: Latency set to 66.67ms
D: [alsa-sink-CDC PCM Codec-0] alsa-sink.c: hwbuf_unused=500824
D: [alsa-sink-CDC PCM Codec-0] alsa-sink.c: setting avail_min=64657
I: [alsa-sink-CDC PCM Codec-0] module-loopback.c: Max request changed
D: [alsa-sink-CDC PCM Codec-0] alsa-sink.c: Requesting rewind due to latency change.
I: [alsa-sink-CDC PCM Codec-0] module-loopback.c: Max request changed
D: [alsa-sink-CDC PCM Codec-0] alsa-sink.c: Requested to rewind 524288 bytes.
D: [alsa-sink-CDC PCM Codec-0] alsa-sink.c: Limited to 518560 bytes.
D: [alsa-sink-CDC PCM Codec-0] alsa-sink.c: before: 64820
D: [alsa-sink-CDC PCM Codec-0] alsa-sink.c: after: 64820
D: [alsa-sink-CDC PCM Codec-0] alsa-sink.c: Rewound 518560 bytes.
D: [alsa-sink-CDC PCM Codec-0] sink.c: Processing rewind...
D: [alsa-sink-CDC PCM Codec-0] sink-input.c: Have to rewind 518560 bytes on render memblockq.
D: [alsa-sink-CDC PCM Codec-0] source.c: Processing rewind...
I: [bluetooth] module-loopback.c: Skipping 0 bytes
D: [pulseaudio] module-suspend-on-idle.c: Source bluez_source.1C_56_FE_9D_1B_0E becomes busy, resuming.
D: [pulseaudio] core-subscribe.c: Dropped redundant event due to change event.
I: [pulseaudio] module.c: Loaded "module-loopback" (index: #22; argument: "source="bluez_source.1C_56_FE_9D_1B_0E" source_dont_move="true" sink_input_properties="media.role=music"").
I: [pulseaudio] module.c: Loaded "module-bluez5-device" (index: #21; argument: "path=/org/bluez/hci0/dev_1C_56_FE_9D_1B_0E").
D: [pulseaudio] bluez5-util.c: Transport /org/bluez/hci0/dev_1C_56_FE_9D_1B_0E/fd11 available for profile a2dp_source
D: [pulseaudio] bluez5-util.c: Unknown interface org.freedesktop.DBus.Introspectable found, skipping
D: [pulseaudio] bluez5-util.c: Unknown interface org.bluez.MediaPlayer1 found, skipping
D: [pulseaudio] bluez5-util.c: Unknown interface org.freedesktop.DBus.Properties found, skipping
D: [pulseaudio] bluez4-util.c: dbus: interface=org.freedesktop.DBus.ObjectManager, path=/, member=InterfacesAdded
D: [pulseaudio] bluez5-util.c: Properties changed in adapter /org/bluez/hci0
D: [pulseaudio] bluez4-util.c: dbus: interface=org.freedesktop.DBus.Properties, path=/org/bluez/hci0, member=PropertiesChanged
I: [pulseaudio] client.c: Created 25 "Native client (UNIX socket client)"
I: [pulseaudio] protocol-native.c: Client authenticated anonymously.
I: [pulseaudio] client.c: Freed 25 "Native client (UNIX socket client)"
I: [pulseaudio] protocol-native.c: Connection died.
I: [pulseaudio] client.c: Created 26 "Native client (UNIX socket client)"
I: [pulseaudio] protocol-native.c: Client authenticated anonymously.
D: [pulseaudio] protocol-native.c: Protocol version: remote 29, local 29
D: [pulseaudio] protocol-native.c: SHM possible: no
D: [pulseaudio] protocol-native.c: Negotiated SHM: no
D: [pulseaudio] protocol-native.c: Client amixer changes volume of sink alsa_output.platform-1c22c00.codec.analog-stereo.
D: [alsa-sink-CDC PCM Codec-0] alsa-sink.c: Requested to rewind 524288 bytes.
D: [alsa-sink-CDC PCM Codec-0] alsa-sink.c: Limited to 18200 bytes.
D: [alsa-sink-CDC PCM Codec-0] alsa-sink.c: before: 2275
D: [alsa-sink-CDC PCM Codec-0] alsa-sink.c: after: 2275
D: [alsa-sink-CDC PCM Codec-0] alsa-sink.c: Rewound 18200 bytes.
D: [alsa-sink-CDC PCM Codec-0] sink.c: Processing rewind...
D: [alsa-sink-CDC PCM Codec-0] sink-input.c: Have to rewind 18200 bytes on render memblockq.
D: [alsa-sink-CDC PCM Codec-0] source.c: Processing rewind...
I: [pulseaudio] module-device-restore.c: Storing volume/mute for device+port sink:alsa_output.platform-1c22c00.codec.analog-stereo:analog-output.
I: [pulseaudio] client.c: Freed 26 "ALSA plug-in [amixer]"
I: [pulseaudio] protocol-native.c: Connection died.
I: [pulseaudio] client.c: Created 27 "Native client (UNIX socket client)"
I: [pulseaudio] protocol-native.c: Client authenticated anonymously.
D: [pulseaudio] protocol-native.c: Protocol version: remote 29, local 29
D: [pulseaudio] protocol-native.c: SHM possible: no
D: [pulseaudio] protocol-native.c: Negotiated SHM: no
I: [pulseaudio] client.c: Freed 27 "ALSA plug-in [amixer]"
I: [pulseaudio] protocol-native.c: Connection died.
I: [pulseaudio] client.c: Created 28 "Native client (UNIX socket client)"
I: [pulseaudio] protocol-native.c: Client authenticated anonymously.
D: [pulseaudio] protocol-native.c: Protocol version: remote 29, local 29
D: [pulseaudio] protocol-native.c: SHM possible: no
D: [pulseaudio] protocol-native.c: Negotiated SHM: no
I: [pulseaudio] client.c: Freed 28 "pactl"
I: [pulseaudio] protocol-native.c: Connection died.
/etc/pulse/daemon.conf
daemonize = no
allow-module-loading = yes
allow-exit = no
use-pid-file = yes
system-instance = yes
high-priority = yes
realtime-scheduling = no
log-target = journal
resample-method = ffmpeg
enable-remixing = no
enable-lfe-remixing = no
flat-volumes = yes
default-sample-format = s32le
default-sample-rate = 44000
alternate-sample-rate = 192000
default-sample-channels = 2
default-fragments = 10
default-fragment-size-msec = 50
/etc/pulse/client.conf
extra-arguments = --log-target=syslog --system --disallow-exit -v
/etc/pulse/system.pa
.ifexists module-udev-detect.so
load-module module-udev-detect
.else
load-module module-detect
.endif
.ifexists module-esound-protocol-unix.so
load-module module-esound-protocol-unix auth-anonymous=1
.endif
load-module module-native-protocol-unix auth-anonymous=1
load-module module-stream-restore
load-module module-device-restore
load-module module-default-device-restore
load-module module-rescue-streams
load-module module-always-sink
load-module module-suspend-on-idle
load-module module-position-event-sounds
load-module module-bluetooth-discover
load-module module-bluetooth-policy
load-module module-switch-on-connect
/etc/pulse/default.pa
.nofail
.fail
load-module module-device-restore
load-module module-stream-restore
load-module module-card-restore
load-module module-augment-properties
load-module module-switch-on-port-available
.ifexists module-udev-detect.so
load-module module-udev-detect
.else
load-module module-detect
.endif
.ifexists module-jackdbus-detect.so
.nofail
load-module module-jackdbus-detect channels=2
.fail
.endif
.ifexists module-bluetooth-policy.so
load-module module-bluetooth-policy
.endif
.ifexists module-bluetooth-discover.so
load-module module-bluetooth-discover
.endif
.ifexists module-esound-protocol-unix.so
load-module module-esound-protocol-unix
.endif
load-module module-native-protocol-unix
.ifexists module-gconf.so
.nofail
load-module module-gconf
.fail
.endif
load-module module-default-device-restore
load-module module-rescue-streams
load-module module-always-sink
load-module module-intended-roles
load-module module-suspend-on-idle
.ifexists module-console-kit.so
load-module module-console-kit
.endif
.ifexists module-systemd-login.so
load-module module-systemd-login
.endif
load-module module-position-event-sounds
load-module module-role-cork
load-module module-filter-heuristics
load-module module-filter-apply
接收器输入被“静音”。
0 ol-blue /etc/pulse # pactl list sink-inputs
Sink Input #0
Driver: module-loopback.c
Owner Module: 16
Client: n/a
Sink: 0
Sample Specification: s16le 2ch 44100Hz
Channel Map: front-left,front-right
Format: pcm, format.sample_format = "\"s16le\"" format.rate = "44100" format.channels = "2" format.channel_map = "\"front-left,front-right\""
Corked: yes
Mute: no
Volume: front-left: 1 / 0% / -288.99 d, front-right: 1 / 0% /
-288.99 d
balance 0.00
Buffer Latency: 0 usec
Sink Latency: 0 usec
Resample method: speex-fixed-1
Properties:
media.role = "music"
module-stream-restore.id = "sink-input-by-media-role:music"
media.name = "Loopback from MotoG3"
media.icon_name = "audio-card-bluetooth"
ALSA 水槽:
0 ol-blue /etc/pulse # pactl list sinks
Sink #0
State: SUSPENDED
Name: alsa_output.platform-1c22c00.codec.analog-stereo
Description: sun4i-codec Analog Stereo
Driver: module-alsa-card.c
Sample Specification: s32le 2ch 44000Hz
Channel Map: front-left,front-right
Owner Module: 1
Mute: no
Volume: front-left: 1 / 0% / -288.99 d, front-right: 1 / 0% / -288.99 d
balance 0.00
Base Volume: 65536 / 100% / 0.00 dB
Monitor Source: alsa_output.platform-1c22c00.codec.analog-stereo.monitor
Latency: 0 usec, configured 0 usec
Flags: HARDWARE DECIBEL_VOLUME LATENCY
Properties:
alsa.resolution_bits = "24"
device.api = "alsa"
device.class = "sound"
alsa.class = "generic"
alsa.subclass = "generic-mix"
alsa.name = ""
alsa.id = "CDC PCM Codec-0"
alsa.subdevice = "0"
alsa.subdevice_name = "subdevice #0"
alsa.device = "0"
alsa.card = "0"
alsa.card_name = "sun4i-codec"
alsa.long_card_name = "sun4i-codec"
alsa.driver_name = "sun4i_codec"
device.bus_path = "platform-1c22c00.codec"
sysfs.path = "/devices/platform/soc at 01c00000 /1c22c00.codec/sound/card0"
device.string = "hw:0"
device.buffering.buffer_size = "524288"
device.buffering.fragment_size = "65536"
device.access_mode = "mmap+timer"
device.profile.name = "analog-stereo"
device.profile.description = "Analog Stereo"
device.description = "sun4i-codec Analog Stereo"
module-udev-detect.discovered = "1"
device.icon_name = "audio-card"
Ports:
analog-output: Analog Output (priority: 9900)
Active Port: analog-output
Formats:
pcm
答案1
我相信我调查的 PulseAudio 蓝牙 a2dp 配置文件处理问题是相同的。即,对于相同的pulsaudio项目,媒体角色音量的处理方式与对于具有另一媒体角色的相同项目的媒体角色音量的处理方式不同。
这里蓝牙 a2dp_source 将媒体角色设置为音乐,结果发现在创建环回模块接收器时接收器输入音量设置为零。解决方法是将接收器输入设置为非零一次,然后保持在该值。
我设置了应用gnome 控制中心的音量,其“音量级别”对每个应用程序都有音量控制,即没有标签的应用程序设置为 0%,我将其设置为 100%,现在连接时声音始终设置为 100%蓝牙设备。问题已解决。
请注意,我能够使用本机 Pulseaudio(无蓝牙)重现无音量问题:
PULSE_PROP='media.role=music' paplay <wave file>
而随机媒体角色则很好:
PULSE_PROP='media.role=blob' paplay <wave file>
。我还可以通过 gnome-control-center 声音“音量级别”修复它。
它还可能需要这个 pactl 修复: 如何在播放不同音源时降低背景音乐流的音量?
有一个记录的 CLI 用于更改每个客户端的卷...例如,pactl set-sink-input-volume 1384 100%,其中 1384 是客户端编号。秘密在于,对于播放客户端,它们被称为“接收器输入”(对于录制客户端,它们被称为“源输出”)。
即可以使用以下命令将接收器输入量设置为 100%,
pactl set-sink-input-volume 350 100%
并使用以下命令将接收器输入量设置为 0%:
pactl set-sink-input-volume 350 0%
其中 350 是接收器输入指数。
奇怪的是 pactl sink-input-volume 和 gnome-control-center 应用程序音量级别修复为正交。如果1为0%则没有声音。
尽管我非常有信心使用 gnome-control-center 修复了蓝牙环回,但我的接收器输入音量最初为 0%。我对 Paplay 的测试肯定混淆了调试过程。但事后我可以确认应用程序级别和接收器输入量都需要提高。