我正在尝试将蓝牙耳机连接到我的 RPI。我的设置如下:
- archlinux-arm,内核:linux-raspberrypi 3.12.23-1
- bluez4 4.101-4 来自 AUR , build 并安装
- bluez-tools 0.1.38-3
- bluez-utils 5.20-1
- pulseaudio 5.0-1
- pulseaudio-alsa 2-3
我扫描设备,成功配对,添加为受信任并连接:
hcitool scan
bluez-simple-agent hci0 <MAC>
bt-device --set <MAC> Trusted 1
bt-audio -c <MAC>
此后,设备状态如下( bt-device -i <MAC>
输出):
[00:23:7F:2A:3B:24]
Name: PLT 510
Alias: PLT 510 [rw]
Address: 00:23:7F:2A:3B:24
Icon: audio-card
Class: 0x200404
Paired: 1
Trusted: 1 [rw]
Blocked: 0 [rw]
Connected: 1
UUIDs: [Headset, Handsfree]
所以,一切看起来都很棒,对吧?嗯,不完全是。
问题是当我尝试播放音频时,因为 PulseAudio 似乎无法识别它并且没有注册 source
和sink
条目:
[root@alarmpi bluetooth]# pactl list sources short
0 alsa_output.platform-bcm2835_AUD0.0.analog-stereo.monitor module-alsa-card.c s16le 2ch 44100Hz IDLE
[root@alarmpi bluetooth]# pactl list sinks short
0 alsa_output.platform-bcm2835_AUD0.0.analog-stereo module-alsa-card.c s16le 2ch 44100Hz SUSPENDED
我已经检查过 module-bluetooth-policy
和module-bluetooth-discover
模块已加载。甚至尝试卸载并再次加载:
pactl unload-module module-bluetooth-discover
pactl load-module module-bluetooth-discover
已成功加载模块,但仍未显示在 sources
中也不sinks
列表。
我还尝试配置 /etc/bluetooth/audio.conf
启用不同的选项,例如:
Enable=Source,Sink,Media,Socket
Enable=Source,Sink,Headset,Gateway,Control,Media,Socket
Enable=Source,Sink,Media
...
但这并没有改变任何事情。
我已经没有想法了... 为什么 PulseAudio 无法识别它?有什么我错过的吗?我需要以某种特殊方式配置 PulseAudio 吗?
最佳答案
与此同时,我已设法解决此问题,以下是对我有用的步骤。
有问题的操作系统是archlinux-arm。
安装
安装以下软件包:
- bluez4-4.101-4
- bluez-tools-0.1.38-3
- bluez-utils 5.21-2
- libpulse-4.0-6
- pulseaudio-4.0-6
- pulseaudio-alsa-2-2
- alsa-utils
Note:
I have managed to get PulseAudio to detect my Bluetooth headset using the specific package versions listed here. Some other versions worked also, but most combinations I tried had issues that I couldn't resolve.
Most packages can be built and installed from AUR (bluez4, bluez-tools, ...), and others can be installed easily withpacman
.
额外准备
安装这些软件包版本后,我们不需要 pacman
以便稍后我们进行系统升级时更新它们。为了防止这种情况,我们将以下行添加到 /etc/pacman.conf
中:
IgnorePkg = libpulse pulseaudio pulseaudio-alsa bluez bluez-tools
PulseAudio 存在无法与 bluez4
配合使用的问题,尤其是未能切换到 A2DP
使用bluez4
时的配置文件版本 4.1 及更高版本和 pulseaudio
3.0 或更高版本。这可以通过省略 Socket
来解决/etc/bluetooth/audio.conf
中启用列表中的参数:
# Enable=Headset,Sink,Source,Socket
Enable=Headset,Sink,Source
如果这还不够,请尝试添加额外的行:
Disable=Socket
正在运行
现在是启用并启动 bluetooth
的时候了服务:
systemctl enable bluetooth
systemctl start bluetooth
我们可以通过 hcitool
发现我们的设备, bt-adapter
或bt-device
,并连接到它。例如,使用后者:
bt-device -d
bt-device -c <MAC>
bt-device --set <MAC> Trusted 1
bt-audio -c <MAC>
第一个命令发现设备,第二个命令通过其 MAC 地址连接到该设备。第三个将其设置为受信任,以便我们稍后在范围内时自动连接到它。最后一个命令将其连接为音频设备。之后,它应该可以在 pulseaudio
中找到。 。
与 PulseAudio 一起使用
通过 pulseaudio --start
启动 PA .
检查源和接收器是否被正确识别:
pactl list sources short
pactl list sinks short
您应该会看到列出的 BT 接收器和源,这意味着 PA 已检测到它们。请注意接收器和源旁边的 ID 值。使用它们将您的 BT 设置为默认接收器/源:
pacmd set-default-source <BT_SOURCE_ID>
pacmd set-default-sink <BT_SINK_ID>
您可以通过 pacmd list-cards
找到 BT 卡 ID 及其支持的配置文件。 。您可能至少会看到 A2DP
和HSP
那里列出了配置文件。您可以像这样在它们之间切换:
# pacmd set-card-profile <card_id> <profile_name>
pacmd set-card-profile 1 a2dp
pacmd set-card-profile 1 hsp
自动连接
包bluez-tools包含名为bt-monitor的工具,该工具捕获来自bluetoothd
的D-Bus信号守护进程并为检测到的已配对(且受信任)的设备启动连接。运行bt-monitor
并通过关闭然后打开 BT 耳机进行测试。
关于bluetooth - Pulseaudio 未检测到蓝牙耳机,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24580155/