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: 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:
  • 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
  • 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
  • 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
  • Finally you may have to experiment with the audio buffer etc settings to get the best sound.
leveller
 
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
ccomred
 
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.
janui
User avatar
janui
 
Posts: 699
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?
tuna
 
Posts: 18
Joined: 30 Oct 2016, 17:39

Re: Bluetooth headphone support (and mod guide)

Postby Toube » 20 Oct 2018, 09:26

Hi,
So this would also enable you to stream music from your mobile phones local storage using Bluetooth connection to Rpi?
Would definitely be a good feature to be able to stream music from you mobile phone directly to your rpi?

-Toube
Toube
 
Posts: 131
Joined: 10 Oct 2018, 08:10

Re: Bluetooth headphone support (and mod guide)

Postby Toube » 20 Oct 2018, 11:56

Looks like they found a way to get it working in volumio
https://volumio.org/forum/volumio-bluet ... t8937.html
Toube
 
Posts: 131
Joined: 10 Oct 2018, 08:10

Re: Bluetooth headphone support (and mod guide)

Postby janui » 20 Oct 2018, 21:13

Hi all,
Rune v5b has all the components which are required for Bluetooth pre-installed, the services are disabled. During the build of 0.5b Gearhead solved the problems relating to building these packages. I have not had time to fully test all the components on armv6 and armv7, but simple connections of a Bluetooth keyboard and mouse have worked on the armv6 version. If you don’t use Rune v5b you can download the arch package set as a zip file using the link: http://www.mediafire.com/file/4yg6zpvth ... h.zip/file (SHA256: 41A18BF401A71B565ED06FBA4E2532C1F0FAE07AF621AC7E2BAAE365A86B50FD).
janui
User avatar
janui
 
Posts: 699
Joined: 20 Dec 2014, 12:55
Location: Ollanda

Re: Bluetooth headphone support (and mod guide)

Postby Toube » 21 Oct 2018, 08:24

janui wrote:Hi all,
Rune v5b has all the components which are required for Bluetooth pre-installed, the services are disabled. During the build of 0.5b Gearhead solved the problems relating to building these packages. I have not had time to fully test all the components on armv6 and armv7, but simple connections of a Bluetooth keyboard and mouse have worked on the armv6 version. If you don’t use Rune v5b you can download the arch package set as a zip file using the link: http://www.mediafire.com/file/4yg6zpvth ... h.zip/file (SHA256: 41A18BF401A71B565ED06FBA4E2532C1F0FAE07AF621AC7E2BAAE365A86B50FD).
janui

Hi Janui,

Sounds good.
Is there a manual for us noobies on how to install the library?

-Toube
Toube
 
Posts: 131
Joined: 10 Oct 2018, 08:10

support RuneAudio Donate with PayPal


Return to Feature request

Who is online

Users browsing this forum: No registered users and 1 guest