- Expand Rune's root partition and filesystem to fill entire SD card (you can follow a guide such as this one: http://elinux.org/RPi_Resize_Flash_Partitions). Unnecessary if you crosscompile bluez-alsa from a PC.
- Install dependencies:
- Code: Select all
pacman -S bluez-libs bluez bluez-utils autoconf automake binutils gcc
- Start bluetooth service and set it to autostart at boot:
- Code: Select all
systemctl start bluetooth
systemctl enable bluetooth
- Install bluez-alsa:
- Code: Select all
git clone https://github.com/Arkq/bluez-alsa/ /root
- Follow installation instructions at https://github.com/Arkq/bluez-alsa/blob ... /README.md
- Set up bluez-alsa to autostart at boot:
- create the file /etc/systemd/system/bluealsa.service:
- Code: Select all
[Unit]
Description=Start the bluez-alsa service
After=bluetooth.service
After=systemd-remount-fs.service
[Service]
ExecStart=/usr/bin/bluealsa
[Install]
WantedBy=bluetooth.target
- Start / enable the service:
- Code: Select all
systemctl daemon-reload
systemctl start bluealsa
systemctl enable bluealsa
- create the file /etc/systemd/system/bluealsa.service:
- Now connect to your bluetooth headphones ('MACaddr' means the MAC address of your bluetooth headset):
- Code: Select all
bluetoothctl
# power on
# scan on
# pair MACaddr (tab completion works)
# trust MACaddr
# connect MACaddr
# exit
- Presuming that went OK you can test the sound is working (replace /foo/bar.mp3 with valid path to mp3 and MACaddr with headphones' MAC address):
- Code: Select all
mpg123 -a bluealsa:HCI=hci0,DEV=MACaddr,PROFILE=a2dp '/mnt/MPD/NAS/foo/bar.mp3'
- Configure bluez-alsa in alsa by creating the file /etc/asound.conf:
- Code: Select all
defaults.bluealsa {
interface "hci0"
device "MACaddr"
profile "a2dp"
}
- add the following to the end of /etc/mpd.conf:
- Code: Select all
audio_output {
type "alsa"
name "ALSA Bluetooth Headset"
device "bluealsa"
mixer_type "software"
auto_resample "no"
auto_format "no"
enabled "no"
}
- increase audio buffer size in /etc/mpd.conf to help eliminate choppy sound:
- Code: Select all
audio_buffer_size "8192"
- That's basically it with regards to set up but there are a couple of issues. Firstly, to play some music through your bluetooth headphones with Runeaudio:
- You have to (unfortunately) use the command line to disable your normal output and enable your headphone output:
- Code: Select all
mpc disable 2 && mpc enable 1
- The numbers (e.g. 1 and 2) may vary depending on how many outputs you have, check the numbers with
- Code: Select all
mpc outputs
- To switch back to your normal output just reverse the commands:
- Code: Select all
mpc enable 1 && mpc disable 2
- You have to (unfortunately) use the command line to disable your normal output and enable your headphone output:
- The second issue is that when you reboot your Runeaudio device, your headphones will not automatically reconnect, nor will your bluetooth controller automatically power on. You can set up a script to do this for you. However the simple one I've used below isn't really an ideal solution since if you switch your headphones off or they go out of range or they're off / not in range when you power on your device then you'll have to run the script manually. Ideally it needs a python script or something like that to regularly check the connection and attempt to reconnect but I haven't got round to writing one yet:
- create file /usr/local/bin/headset:
- Code: Select all
#!/bin/bash
bluetoothctl << EOF
power on
EOF
sleep 1
bluetoothctl << EOF
connect MACaddr
EOF
- Make it executable:
- Code: Select all
chmod 755 /usr/local/bin/headset
- Create file /etc/systemd/system/headset.service:
- Code: Select all
[Unit]
Description=Connect bluetooth headset
After=bluealsa.service
[Service]
ExecStart=/usr/local/bin/headset
[Install]
WantedBy=bluetooth.target
- Start / enable service:
- Code: Select all
systemctl daemon-reload
systemctl start headset
systemctl enable headset
- create file /usr/local/bin/headset:
- Finally you may have to experiment with the audio buffer etc settings to get the best sound.