BlueALSA - andy3471/GBD GitHub Wiki

Background

BlueALSA is a Bluetooth audio ALSA backend. It adds ALSA support to BlueZ v5 and greater.

Bluez acts as a middleware between audio modules which implement Bluetooth audio profiles, and Bluetooth audio devices. BlueALSA registers all known Bluetooth audio profiles in Bluez, and supports an ALSA PCM I/O plugin which allows an ordinary audio application to access a Bluetooth audio stream.

  • NOTE: BlueALSA services are incompatible with PulseAudio Bluetooth. Most desktop distro's have PA installed as the default sound server. In the interests of consistency, only BlueALSA configurations will be considered. Also check out section Disabling PulseAudio Bluetooth.

    On the other hand, a pristine Raspbian v9.4 (Stretch) installation doesn't ship with PA installed. A quick check could be:

    pi@raspberrypi:~ $ apt-cache policy pulseaudio
    pulseaudio:
      Installed: (none)
      Candidate: 10.0-1+deb9u1
      Version table:
         10.0-1+deb9u1 500
         500 http://raspb[...]/raspbian stretch/main armhf Packages
    

BlueALSA on Raspberry PI

  • The official Raspbian Stretch should ship with BlueALSA pre-installed. For instance, a quick check can be done with:

    pi@raspberrypi:~ $ apt-cache policy bluealsa
    bluealsa:
      Installed: 0.7
      Candidate: 0.7
    
    pi@raspberrypi:~ $ ps ax | egrep '(bluetoothd|bluealsa)' | grep -v grep 
      658 ?        Ss     0:00 /usr/lib/bluetooth/bluetoothd
      665 ?        Ssl    0:00 /usr/bin/bluealsa
    

    Otherwise, BlueALSA can be installed from the repositories via apt:

    pi@rapberrypi:~ $ sudo apt-get install bluealsa
    
  • To check whether your Raspberry Pi's on-board BT device has audio capabilities (performed on a RPi Model 3B):

    pi@raspberrypi:~ $ hciconfig -a hci0 | grep Audio
    Service Classes: Rendering, Capturing, Audio, Telephony
    

    Note that the bluealsa daemon should be running before executing this command; bluealsa is what provides the Bluetooth audio services on top of Bluez.

BlueALSA on Desktop GNU/Linux

This configuration is mainly relevant for economy GBD setups (see GBD Architecutre). Some distro's have native package support for BlueALSA. On the other hand, for instance, Ubuntu 16.04 LTS does not include BlueALSA in its official repos and a build from source is required. Please consult the appropriate distro documentation for instructions on BlueALSA build/installation.

Bluetooth Audio Services and Discovery

Before attempting to use BT audio in a GBD setup, check whether the BT devices support BT Audio services. With respect to GNU/Linux, BT Audio services will be available only if the bluealsa daemon is running (i.e. not considering PulseAudio BT services).

For instance, to perform Service Discovery Protocol (SDP) inquiries via sdptool(1):

  • First perform a BT ping between the devices to make sure that they can see each other.

  • SDP request from GNU/Linux PC to RPi:

    $ sdptool browse 11:22:33:68:BC:15 | grep 'Service Name'  | grep Audio
    Service Name: Audio Source
    Service Name: Audio Sink
    
  • SDP request from RPi to GNU/Linux PC:

    $ sdptool browse 43:29:12:DF:78:CD | grep 'Service Name' | grep Audio
    Service Name: Audio Source
    

Alternatively, the info command via the bluetoothctl(1) interface could be used for SDP inquiries. However, it's output (although more verbose/detailed) seems to be less reliable.