Bluetooth headphone support (and mod guide)

Suggestions/requests/ideas for RuneAudio core features and functions

Bluetooth headphone support (and mod guide)

Postby leveller » 25 May 2017, 04:26

I've managed to get this working on Runeaudio 0.4 beta / RPi2. Theoretically I think it should work on other hardware platforms too. As I've noted below there are a couple of issues with my set up partially due to the fact that the feature is not integrated with RuneUI. Perhaps this is something developers could look at at some point, I think it would be a nice feature to have. Here are the steps I took:

  • Expand Rune's root partition and filesystem to fill entire SD card (you can follow a guide such as this one: 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:
  • Set up bluez-alsa to autostart at boot:
    • create the file /etc/systemd/system/bluealsa.service:
      Code: Select all
      Description=Start the bluez-alsa service


    • Start / enable the service:
      Code: Select all
      systemctl daemon-reload
      systemctl start bluealsa
      systemctl enable bluealsa
  • Now connect to your bluetooth headphones ('MACaddr' means the MAC address of your bluetooth headset):
    Code: Select all
    # 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
  • 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

      bluetoothctl << EOF
      power on

      sleep 1

      bluetoothctl << EOF
      connect MACaddr

    • Make it executable:
      Code: Select all
      chmod 755 /usr/local/bin/headset

    • Create file /etc/systemd/system/headset.service:
      Code: Select all
      Description=Connect bluetooth headset



    • Start / enable service:
      Code: Select all
      systemctl daemon-reload
      systemctl start headset
      systemctl enable headset
  • Finally you may have to experiment with the audio buffer etc settings to get the best sound.
Posts: 2
Joined: 20 Apr 2017, 17:08

Re: Bluetooth headphone support (and mod guide)

Postby ccomred » 02 Mar 2018, 13:45

Hi, I have Problems to compile bluez-alsa.

[root@runeaudio ~]# cd bluez-alsa/build/
[root@runeaudio build]# ../configure --enable-aac --enable-debug
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking for gcc... gcc
checking whether the C compiler works... no
configure: error: in `/root/bluez-alsa/build':
configure: error: C compiler cannot create executables
See `config.log' for more details
Posts: 1
Joined: 02 Mar 2018, 13:43

Re: Bluetooth headphone support (and mod guide)

Postby janui » 02 Mar 2018, 22:41

Hi ccomred,
checking whether the C compiler works... no
configure: error: in `/root/bluez-alsa/build':
configure: error: C compiler cannot create executables
I have exactly the same problem trying to build another package. The error appeared first on Monday 26-02-2018, I have now tried the package build on 4 different historical Linux versions with the same result. By doing this I have isolated the problem to a group of packages. One of these is causing the problem: autoconf automake binutils bison fakeroot flex gcc make gettext groff m4 patch which
I have found no recent posts on the net reporting this issue. I has the feeling that I was doing something stupid (it is still a possibility), but seeing your post seems to point to a structural problem.
If you find a solution please post it, I will do the same.
User avatar
Posts: 299
Joined: 20 Dec 2014, 12:55
Location: Ollanda

Re: Bluetooth headphone support (and mod guide)

Postby tuna » 18 Aug 2018, 07:49

Did you ever find a solution to GCC not being able to compile?
Posts: 18
Joined: 30 Oct 2016, 17:39

support RuneAudio Donate with PayPal

Return to Feature request

Who is online

Users browsing this forum: No registered users and 0 guests