Thursday, July 24, 2008

Bluetooth Stereo Headset A2DP Pairing in Ubuntu 8.04 Hardy

Update: Someone created a better explanation here:

Well, I got my HTC stereo a2dp headset in.  While pairing was very straight-forward on my WinMo phone, it wasnt quite so obvious in Ubuntu.

The problem is this:  You try to browse for the device, select it, and you receive an OBEX error.  Apparently behind the scenes the gnome bluetooth manager is trying to establish an OBEX file connection with the device which a Headset generally does not have, thus you will get an OBEX error before the pairing process is complete.  Instead you need to establish an audio connection with it to trigger the authentication process, which seemingly the gnome bluetooth manager cannot do via a GUI.

Here is what I did (based on

Determine the MAC address of the headset.  Place device in discovery mode and run
# hcitool scan
Copy the MAC address of the BT adapter

Setup BT Master Mode for devices (avoid skipping):
- Create file /etc/default/hcid.conf  (replace XX with your mac address)

device XX:XX:XX:XX:XX:XX {
name "HTC Headset";
auth enable;
lm master;
passkey "0000";

- Create personal ALSA sound profile as ~/.asoundrc
pcm.bluetooth {
type bluetooth
device XX:XX:XX:XX:XX:XX
profile "hifi"

Initiate a connection and start the pairing process
# mplayer -ao alsa:device=bluetooth someaudiofile.mp3

Gnome will popup an authentication dialog, enter in your passkey, and your device will be forever paired in the system.  Done.

** For General Pulse System Audio  **
- Install PulseAudio Volume Control:
# apt-get install pavucontrol
- Load modules for bluetooth:
# pactl load-module module-alsa-sink device=bluetooth
# pactl load-module module-alsa-source device=bluetooth

- Run a program using PulseAudio
# totem
- Run PulseAudio Volume Control:
# pavucontrol
- Right Click playback audio source and select "Bluetooth".
- Whoila


  1. So far so good it works but right click and back to the default speakers gives me an error! (connection failed) and sound is totally terminated. Only a full restart brings it back.

    Do I mis something?


  2. No, you didnt miss anything. The same thing happens to me as well when trying to use pulse audio. You'll also find that after a couple of hours, pulse audio will eventually crash with BT devices. Pulse audio integration with the bluetooth devices seems buggy at best. I would suggest youfind or file a bug report.

    When I am listening to music, I just stick with Mplayer using the alsa device bluetooth driver ( almost everything I do with media, I do with mplayer anyway )

    BTW: Most things in linux dont require a full computer restart. For example to bring back the audio, I execute the following:
    sudo /etc/init.d/pulseaudio restart

  3. Great guide!

    Instead (or addition) of loading the modules by hand (pactl...) I suggest to add these lines (without the first pactl) to the file ~/.pulse/

    @dallco, jason: I'm using my bluetooth headphones via PulseAudio for half an hour or so, and have got no connection failures yet. But I noticed that if you change a program output (Amarok, for instance) from bluetooth to the ALSA speakers, PulseAudio crashes. I couldn't even restart PulseAudio with sudo /etc/init.d/pulseaudio restart, neither by running sudo pulseaudio by hand, it just works when I restart the computer. Pretty strange.

  4. [...] Fonte: Sharpee’s Space - Bluetooth Stereo Headset A2DP Pairing in Ubuntu 8.04 Hardy [...]

  5. Great! Helped me a lot. Cheers!

  6. Works as written above in Ibex with a Motorola HD 820 headset and generic dongle (although the range leaves something to be desired). Thanks for posting!

  7. fantastic thanks a looot... u made my day...


  8. I can reproduce the bug too. We should definitely report it. Has this already been done? Otherwise I can do it. Please just let me know.

    After pulseaudio crashes, there's no need to reboot the machine. A logout/login solves the problem.

  9. The article is ver good. Write please more