Earlier this year, I showed you how to get high-quality A2DP audio streaming to your Bluetooth headphones. And while that method of connecting your headphones to a music player does work fine, it really only works with media players and anything else set up to specifically play to your headset. What if you want to watch a Flash video with A2DP audio? How about play a game of Nexuiz through the headset? Well, with that implementation, you can’t.
And next week, with the release of Ubuntu 8.10, that method will not even work anymore due to a new incompatible version of Bluez. But on the flipside, we really don’t even need to do that anymore.
Most distributions include a somewhat recent version of PulseAudio. Love it or hate it, it becomes an excellent tool for the job. Using PulseAudio sinks (outputs), we are able to create a new device visible for Pulse to play to. This means not only your music player, but also your games, websites, and everything else, can play through your wireless headset.
Note: If you used any of the instructions from the previous article, undo them entirely. First make sure your GStreamer output is set back to speaker mode if you used it. Then, delete the .a2dp folder in your home directory. Finally, remove the A2DP Connection script from System > Preferences > Sessions. Leaving anything laying around could interfere with the new process.
Also note that these are merely some things to try out. They are by no means complete; real, full Bluetooth support will come in a later PulseAudio release. PulseAudio 0.9.13 includes the start of this work, but it isn’t too use-friendly at the moment.
Let’s get started. Open up the file .asoundrc in your home directory (create it if you can’t find it), and change its contents to something like this:
pcm.bluetooth {
type bluetooth
device "00:00:00:00:00:00"
}
Replace the device line with the MAC address of your headphones. To find the MAC address, put the headset in pairing mode, and run hcitool scan. Also, if you headphones aren’t already paired with your computer, do that now using the Bluetooth applet in the notification area.
Save that file and log out and back in again to make ALSA re-read the configuration. Now we can set up PulseAudio with a simple one-liner:
pactl load-module module-alsa-sink device="bluetooth"
Be sure your headphones are on. When you see a number appear on the command line, they are ready. Pulse will automatically turn on and off the headphones as needed when it wants to play sound. Caveat: You cannot set this to run at startup, as it will sometimes fail. You can, however, add it as a panel launcher and enable your headphones with a single click.
Now go ahead and open up Rhythmbox or another music player (or something else you know uses PulseAudio) and play a track. If you don’t get any audio, check to make sure your headphones are on and paired properly, and try the above command again. If the audio still comes out of your speakers, then you will want to re-route the audio.
To do this, install the pavucontrol (PulseAudio Volume Control) application, which may be present on some distributions already. Open it up, and go to the Output Devices tab. Find your headset in the list (labeled “bluetooth”) and click the down arrow on the right. Check Default, and try playing audio again. If it still comes out of the speakers, then Pulse is remembering previous settings. Leave the music playing, and go to the Playback tab. Click the down arrow next to the active stream (probably labeled as your music player and current song) and select Move To and then “bluetooth”. Wait a moment, and the audio should then route to the headphones. From that point on, Pulse should remember that it should always play to your headphones for that application if they are available.
Feel free to experiment with different setups to find out what works best for you. If things don’t work out the first time, simply keep trying. Share your findings in the comments below.
Bonus tip: AVRCP
Just like in the last article, you can enable AVRCP (play/next button) support by adding uinput to the end of /etc/modules. Reboot and your headphones should work!


FOSSwire » A2DP (Stereo Bluetooth Headset) on Linux wrote:
[...] These instructions will eventually be obsolete. This will not work with Bluez 4 or above, included with Ubuntu 8.10+. PulseAudio is also set to [...]
# Posted on 25-Oct-08 at 1:34 am
Setting up your A2DP enabled Bluetooth headset to work with Linux « Venkatesan Padmanabhan wrote:
[...] Yes, yesterday think luck was in my favor.When I searched for “jabra and linux” in google, I got what I needed within the first few links. Updated Instructions @ http://fosswire.com/2008/10/25/better-bluetooth-audio/ [...]
# Posted on 25-Oct-08 at 4:27 am
Gert van Dijk wrote:
Thanks for this great how-to! I just did a reinstall with Ubuntu 8.10 and was glad to find a how-to to match the new software. Still some problems, though.
- AVRCP isn’t working anymore. It was in Hardy with the same headset (Nokia BH-503). That really is a pity.
- When some other non-Gstreamer program starts playing audio the Gstreamer application fails to play audio through the headset and eventually won’t respond (Rhythmbox in my case). The non-Gstreamer application plays the audio through the speakers.
# Posted on 29-Oct-08 at 11:06 am
nomasteryoda wrote:
Yup… Similarly to Dijk’s post above, I have installed Ubuntu 8.10 Itchy Ibex (I know its Intrepid but that makes me think of the Starship). Following your directions, I got my HT-820 headset working and the sound is so clear and loud now I can’t believe the difference from a2dpd. In both Ubuntu 8.04 and Sidux installs I had used your directions for the bluetooth toggle, but this is far superior and just works.
Combined with the new ability to use my smartphone PDA to get web access in the laptop and rhythmbox’s album art download, I’ve got one mean media playing laptop.
I just need to get AVRCP working now.
thanks for putting this info down,
nmy
# Posted on 30-Oct-08 at 5:16 pm
Jacob wrote:
nomasteryoda:
Ah, thanks, I forgot about the AVRCP support. Added to the end of this article.
# Posted on 30-Oct-08 at 5:26 pm
The Bluez, Pt. 1: Connectivity | FINAL COLUMN wrote:
[...] UPDATE: FOSSwire notes that the above instructions are not supported in Ubuntu 8.10. They have provided these instructions instead, which I have tested and confirmed to work on Ubuntu 8.10: Better Bluetooth Audio. [...]
# Posted on 08-Nov-08 at 5:39 pm
Carlos Alexandre wrote:
I’m using Kubuntu 8.10 (Hardy) 64-bits, works fine with me
including the remote control(avrcp) with amarok
Could be something with the bluetooth adapter
a note, when insalling it’s not need to reboot, only need type (root) modprobe uinput
# Posted on 17-Nov-08 at 4:19 pm
Carl wrote:
Hi, this seems like a nice guide. However, I do have some troubles. First off, if I use the hcitool command, it ruins the bluetooth manager and I need to reinstall it (tried rebooting to no avail). After a lot of trouble getting hold of the Bluetooth ID number for the headset (Jabra BT2040) I finally got my .asoundrc properly set up and could run the pactl load-module module-alsa-sink device=”bluetooth” command, and it actually seems to work because my headset hums up and is clearly being affected by the command.. however, after a little while I get “Failure: Timeout” instead of the number you said I would get.. Any idea what I should do?
# Posted on 17-Nov-08 at 9:15 pm
Better Bluetooth Audio « Useful Ubuntu Links wrote:
[...] FOSSwire Posted in Workarounds. [...]
# Posted on 18-Nov-08 at 12:20 pm
Jeremy Pointer wrote:
This works beutifully for me…. almost the problem I have is that pulseaudio keeps crashing for e.g. when running sound test to the headset - also it would be helpful if there was a way to automatically run the pactl when the headset is turned on / connection is made to it - how would this be achieved ?
# Posted on 22-Nov-08 at 8:15 am
Jeremy Pointer wrote:
FWIW: it took me a while to recreate the problem but this is the error pulseaudio outputs:
ALSA lib pcm_bluetooth.c:712:(bluetooth_a2dp_hw_params) BT_SETCONFIGURATION failed : Input/output error(5)
W: alsa-util.c: Unable to determine current swparams: Operation not permitted
ALSA lib control.c:909:(snd_ctl_open_noupdate) Invalid CTL bluetooth
pulseaudio: pcm_bluetooth.c:797: bluetooth_playback_poll_revents: Assertion `pfds[1].fd >= 0′ failed.
# Posted on 22-Nov-08 at 8:34 am
Vadim Atlygin wrote:
Hi, is there a way to make pulseaudio listen to a mic from headset also?
# Posted on 23-Nov-08 at 3:18 am
Aspic wrote:
As I’m a stupid boy, I used the instruction of the previous page, using a2dp.sh
I removed the .a2dp directory and the A2DP Connection script.
But since I used the script a2dp.sh, my intrepid ibex isn’t able to pair any device with my comp.
I always have a timeout…
hidd –connect says : “Can’t get device information: Connection timed out”
Need help, please !! ;o)
# Posted on 26-Nov-08 at 12:05 am
Aspic wrote:
After playing with .deb (install, uninstall, reinstall, etc…), it works again. Pfiouuu, how lucky am I :o)
# Posted on 26-Nov-08 at 8:03 am
Prof. Dr. Morpheus wrote:
Thanks, it worked great!
# Posted on 27-Dec-08 at 1:22 pm