0

just purchased my first Raspi. I've installed Raspbian Jessie mainly for Bluez5, since I'm interested in the AVRCP features of Bluez5.

I'm struggling with getting audio to pump out over bluetooth. I was able to successfully pair and connect to a little JBL Bluetooth speaker I have using the hci* tools, but I'm lost on how to redirect audio over bluetooth. I'm really interested in using mplayer in slave mode from a terminal, so command-line only solutions that don't rely on X would be appreciated.

Most of the guides/tutorials I've found seem to be for Bluez4. I often see references to bt-audio, which doesn't appear to exist for Jessie (maybe removed as part of the Bluez5 redesign). From what I understand, Bluez5 dropped support for ALSA so I must use PulseAudio, but even with that info I'm still fairly lost.

Can anyone outline the procedure for piping audio from the Raspi out over a BT connection to an A2DP compliant device in Raspbian Jessie?

2 Answers 2

1

I'm in a similar position. But as of Nov 27,2015 I don't think this is supported. I totally agree with you about the documentation issue. When I execute bluetoothctl and poke around this is what I found. Here's why it doesn't work:

Bluetooth capability mismatch- Raspberry Pi bluetooth doesn't report a UUID for A2DP, I'm expecting that it should. Also /etc/bluetooth doesn't have an audio.conf file like everyone on the web references. I think that has meaning.

[CHG] Device 20:13:07:17:AC:47 Connected: yes
[JETech S2020]# info 20:13:07:17:AC:47
Device 20:13:07:17:AC:47
        Name: JETech S2020
        Alias: JETech S2020
        Class: 0x240404
        Icon: audio-card
        Paired: yes
        Trusted: yes
        Blocked: no
        Connected: yes
        LegacyPairing: no
        UUID: Headset                   (00001108-0000-1000-8000-00805f9b34fb)
        UUID: Audio Sink                (0000110b-0000-1000-8000-00805f9b34fb)
        UUID: A/V Remote Control Target (0000110c-0000-1000-8000-00805f9b34fb)
        UUID: Advanced Audio Distribu.. (0000110d-0000-1000-8000-00805f9b34fb)
        UUID: A/V Remote Control        (0000110e-0000-1000-8000-00805f9b34fb)
        UUID: Handsfree                 (0000111e-0000-1000-8000-00805f9b34fb)
[CHG] Controller 00:19:0E:15:62:FA Discoverable: no
[JETech S2020]# info 00:19:0E:15:62:FA
Device 00:19:0E:15:62:FA not available
[JETech S2020]# show
Controller 00:19:0E:15:62:FA
        Name: raspberrypi
        Alias: raspberrypi
        Class: 0x0c041c
        Powered: yes
        Discoverable: no
        Pairable: yes
        UUID: PnP Information           (00001200-0000-1000-8000-00805f9b34fb)
        UUID: Generic Access Profile    (00001800-0000-1000-8000-00805f9b34fb)
        UUID: Generic Attribute Profile (00001801-0000-1000-8000-00805f9b34fb)
        UUID: A/V Remote Control        (0000110e-0000-1000-8000-00805f9b34fb)
        UUID: A/V Remote Control Target (0000110c-0000-1000-8000-00805f9b34fb)
        UUID: Audio Source              (0000110a-0000-1000-8000-00805f9b34fb)
        UUID: Audio Sink                (0000110b-0000-1000-8000-00805f9b34fb)
        Modalias: usb:v1D6Bp0246d0517
        Discovering: no
1

I've got audio piping into a bluetooth speaker with a pi 3 via pulse and MPD.

Here's how I got it working:

Factory install raspbian jessie (had trouble with lite and bluetooth permissions) onto the raspberry pi 3. Run raspi-config in terminal and expand the filesystem, then reboot. Install pulseaudio bluetooth support via the following command.

sudo apt-get install pulseaudio-module-bluetooth

You may want to update apt-get first using the command:

sudo apt-get update

Restart the system. Once it reboots we will enter the bluetooth administration tool using the following command:

bluetoothctl

This will enter a bluetooth administration console. From here we can scan for our speaker and pair it. Pulseaudio must be running for this to work, but it will start by default after you install the packages above. From the bluetooth console run the following command:

scan on

After a bit you should see your speaker(s) listed. To pair and connect, issue the following commands:

trust 00:02:3C:45:05:E7
pair 00:02:3C:45:05:E7
connect 00:02:3C:45:05:E7

You may not need to issue the trust and pair commands, but several searches showed attempting those commands should any issues arise in pairing. If it still doesn't work make sure the pulseaudio daemon is running, and pulseaudio-module-bluetooth is installed.

After you are connected to the speaker you can exit by simply typing exit in the bluetooth console.

Now you can get your pulseaudio sinks by issuing the command:

pactl list sinks

You should see the speaker listed. You can use this information to configure other applications to route their audio through it. Also, if you install the graphical interface for pulseaudio then you can easily manage the devices for your main desktop, and route the audio from the graphical inteface to the bluetooth speaker. You install it via this command:

sudo apt-get install pavucontrol

You should see the option to manage pulse audio settings afterwards in the main raspbian menu on the desktop.

So this sets up the basic pulseaudio to bluetooth pipe which will work for most desktop applications if you installed pavucontrol. I'm not familiar with MPlayer, but MPD is indeed working via the console. First I installed MPC and MPD:

sudo apt-get install mpd mpc

Then I configured MPD to output to pulse:

sudo nano /etc/mpd.conf

You want to comment out the ALSA output:

# An example of an ALSA output:
#
#audio_output {
#       type            "alsa"
#       name            "My ALSA Device"
#       device          "hw:0,0"        # optional
#       mixer_type      "hardware"      # optional
#       mixer_device    "default"       # optional
#       mixer_control   "PCM"           # optional
#       mixer_index     "0"             # optional
#}

And then enable a pulseaudio output:

audio_output {
    type            "pulse"
    name            "My Pulse Output"
    server          "127.0.0.1"             # optional
    sink            "bluez_sink.00_02_3C_44_C9_43"  # optional
}

I couldn't get it to work without specifying the sink and server, but yours may. Last I had to edit pulseaudio to allow this connection:

sudo nano /etc/pulse/default.pa

Add the following line (it's in there without the arguments, and commented out by default)

load-module module-native-protocol-tcp auth-ip-acl=127.0.0.1;192.168.0.0/16

Now reboot, connect to the speaker via bluetooth ctl, and MPD will output to the bluetooth speaker. You can look up the specifics on MPD, and MPC is a command line client for it that works very well with no extra configuration.

1
  • i'm just curious is bluetooth work before you specify power on and agent on in bluetoothctl before connecting?
    – xdhe
    Commented May 30, 2016 at 12:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.