| title | Setting Up Bluetooth audio with PulseAudio - A2DP only |
|---|---|
| subject | Bluetooth |
Debian jessie is using BlueZ 5 and PluseAudio 5, which are fairly new.
There were major breaking changes in these versions.
Most stuff you find on the Internet will be for BlueZ 4 and PulseAudio 4,
so watch out, those configurations may not work.
PulseAudio 5 only supports the A2DP profile and not Headset profile (HSP) or Hands-free profile (HFP), although it is under development see note 2.
The A2DP profile supports:
UUID: Audio Source
UUID: Audio Sink
This should all be done as root
-
Install pulseaudio:
apt-get install --no-install-recommends pulseaudio pulseaudio-module-bluetooth -
Create a systemd service for running pulseaudio as the pulse user.
Save the following lines as/etc/systemd/system/pulseaudio.service
[Unit]
Description=Pulse Audio
[Service]
Type=simple
ExecStart=/usr/bin/pulseaudio --system --disallow-exit --disable-shm
and reload systemd withsystemctl daemon-reload -
Give the
pulseuser permission to use Bluetooth.
Save this file: pulseaudio-bluetooth.conf to/etc/dbus-1/system.d/pulseaudio-bluetooth.conf -
Paste the following lines to the end of
/etc/pulse/system.pa:
### Automatically load driver modules for Bluetooth hardware
.ifexists module-bluetooth-policy.so
load-module module-bluetooth-policy
.endif
.ifexists module-bluetooth-discover.so
load-module module-bluetooth-discover
.endif -
Start the systemd service:
systemctl start pulseaudio.service -
Run
bluetoothctlto connect the device.
You only need to do the pairing stuff once.
Be sure to substitute the address of the actual device your are connecting to.
Here are the commands:
agent on
default-agent
scan on
pair 11:11:11:11:11:11
trust 11:11:11:11:11:11
connect 11:11:11:11:11:11 -
Now, you should be able to play sound from a remote device on your EV3 without any further configuration.
-
To play sound from the EV3 on a remote device, there are a few more steps.
- add
rootand your own non-root user(s) to theaudioandpulse-accessgroups:
usermod -a -G pulse-access,audio root
usermod -a -G pulse-access,audio myuser - Run
pactl list cards.
The end of the output should look something like this:
Card #1
Name: bluez_card.00_17_E7_BD_1C_8E
Driver: module-bluez5-device.c
Owner Module: 14
Properties:
device.description = "BlueZ 5.23"
device.string = "00:17:E7:BD:1C:8E"
device.api = "bluez"
device.class = "sound"
device.bus = "bluetooth"
bluez.path = "/org/bluez/hci0/dev_00_17_E7_BD_1C_8E"
bluez.class = "0x0c0000"
bluez.alias = "BlueZ 5.23"
device.icon_name = "audio-card-bluetooth"
Profiles:
a2dp_source: High Fidelity Capture (A2DP Source) (sinks: 0, sources: 1, priority: 10, available: yes)
a2dp: High Fidelity Playback (A2DP Sink) (sinks: 1, sources: 0, priority: 10, available: yes)
off: Off (sinks: 0, sources: 0, priority: 0, available: yes)
Active Profile: a2dp
Ports:
unknown-output: Bluetooth Output (priority: 0, latency offset: 0 usec)
Part of profile(s): a2dp
unknown-input: Bluetooth Input (priority: 0, latency offset: 0 usec)
Part of profile(s): a2dp_source
The active profile probably doesn't say a2dp, although in the output above it already has been set.
So set it by running: pactl set-card-profile 1 a2dp
The "1" in this command is the number of the BT card from the output above.
- Now you can play sound using paplay.
Example:paplay -d bluez_sink.00_17_E7_BD_1C_8E /usr/share/sounds/alsa/Front_Center.wav
Possibly error messages likexcb_connection_has_error() returned truehave been seen and not explained.
There seems to be no ill effect on BT audio.
Using my simple non-root user I get:
Failed to create secure directory (/run/user/0/pulse): Permission denied
but playback does work.