Skip to content

Instantly share code, notes, and snippets.

Created January 24, 2012 23:05
Show Gist options
  • Save joergschiller/1673341 to your computer and use it in GitHub Desktop.
Save joergschiller/1673341 to your computer and use it in GitHub Desktop.
A2DP Sink on Ubuntu Linux with bluez (streaming bluetooth stereo audio from smartphone to pc)

Howto Enable and Use A2DP Sink on Ubuntu Linux with Bluez

  1. Add Enable=Source to /etc/bluetooth/audio.conf right after [General].

  2. Find address in form XX:XX:XX:XX:XX:XX of phone with hcitool scan.

  3. Pair and trust smartphone with sudo bluez-simple-agent hci0 XX:XX:XX:XX:XX:XX and sudo bluez-test-device trusted XX:XX:XX:XX:XX:XX yes.

  4. Create loopback in pulseaudio connection bluetooth a2dp source with alsa sink:

pactl load-module module-loopback \
source=bluez_source.XX_XX_XX_XX_XX_XX \

You can find your own values for source and sink with pacmd list-sources and pacmd list-sinks.

Copy link

How would I pair automatically? Example - I want to run the system on a HTPC device, so it should pretend to be A2DP headphones and start playback from any phone which asks for connection.

Copy link

csvan commented Dec 6, 2016

I get Failure: Module initialization failed when running this on 16.10 unfortunately.

Copy link

@csvan check your pactl list. alsa module name is changed.
In my case, I using sink=alsa_output.pci-0000_00_1f.4.analog-stereo.

pactl list | grep Name:
Name: alsa_output.pci-0000_00_1f.4.analog-stereo

Copy link

Worked like a charm on my arch i3 box!! Thanks a lot for this!

Copy link

Thanks a lot, also working on my zotac zbox with kaby lake processor and ubuntu 16.04 LTS :)

Copy link

It did not work with me on raspberry pi

Copy link

sonvirgo commented Feb 27, 2018

If this is for Streaming Audio from Ubuntu -> pulse -> bluetooth -> Phone?
Then it not work on Ubuntu 17.04:
pactl load-module module-loopback source=bluez_source.10_2F_6B_6E_14_06 sink=alsa_output.pci-0000_00_1f.3.analog-stereo
Failure: Module initialization failed

Copy link

HDC67 commented Mar 12, 2018

What does " pacmd list-sources | grep name: " produce?

Does your bluez source have .a2dp_source on the end of the name? I think there's a typo in the original post although things may have changed since then. My machine gives:

test@test:~$ pacmd list-sources | grep name:
        name: <alsa_output.pci-0000_00_05.0.analog-stereo.monitor>
        name: <alsa_input.pci-0000_00_05.0.analog-stereo>
        name: <bluez_source.94_7B_E7_XX_XX_XX.a2dp_source>

So I need

pactl load-module module-loopback source=bluez_source.94_7B_E7_XX_XX_XX.a2dp_source sink=alsa_output.pci-0000_00_05.0.analog-stereo

I'm not getting output but at least the loopback loads without error.

Edit: This worked for me:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment