Bluetooth audio for Linux

Overview | History | Future work | Download & build | Credits | Contact us

Please help test the audio drivers that are built into Bluez
Things are changing rapidly, so while we occasionally release snapshots of the software, the best route to go is to use the current version from cvs.

What we have working now is a scheme with two independent alsa-lib plugins and two independent daemons to run things. When you switch to the alsa-lib device that provides SCO (headset in the example configuration), you can do voice calls and two-way audio. When you switch to the device for a2dp (a2dpd in the example), you get one-way stereo to the headset.

Required packages

These differ from distro to distro, but for Ubuntu, the required packages include:

Download and build

install libsbc:

Note: When asking for a password simply press Enter.

cvs login 
cvs co sbc
cd sbc
./configure --prefix=/usr
sudo make install
install plugz:

cvs login 
cvs co plugz
cd plugz
./configure --prefix=/usr --sysconfdir=/etc
sudo make install

Configure A2DP Driver

This driver allows audio to be sent from an alsa client to a stereo bluetooth headset. The audio is one-way to the set.

Discover the headset's address by doing a bluetooth scan. The headset may need to be in pairing mode for this address to appear:

hcitool scan

The address will look something like 00:14:CF:03:17:8C

cp alsa-plugins/a2dpd/sample.a2dprc ~/.a2dprc

edit ~/.a2dprc to contain the address of your headset on the address= line.

create ~/.asoundrc with simply:

      pcm.a2dpd {
            type a2dpd

and run a2dpd (it's not advised to run it as root). You'll have to arrange for this to be started up subsequently.

You can also have the SDP records for A2DP and AVRCP activated at boot time; this may allow you in some setups to have the headset initiate the connection to a2dpd to start up a stream.

      sdptool add A2SRC
      sdptool add AVRTG

Configure xmms

run xmms, go to prefs (control-p), change output to alsa, click configure, change device from default to a2dpd and select [use software volume control].

If this is a combo headset, turn off your phone first! (Otherwise, the headset will be complicating things by trying to connect to two devices at once)

Turn the headset on in pair mode and hit play in xmms. On the first connect, you should get a popup asking for the pin. Then audio should start.

If your set can do AVRCP, it will be set up to do track advance/pause/stop/play through xmms command-line control. To make AVRCP work with different clients, you'll need to customize ~/.a2dprc.

Configure vlc

This is the only video player I've been able to use with a2dp. You have to edit ~/.vlc/vlcrc and enable the line


For some reason the GUI will not allow you to set this device. Also set "Audio Desynchronization Compensation" in the gui to a value between -200 and -600, depending on your headset's latency, to improve audio/video sync.

Configure Kaffeine

If you are using KDE (ex: Kubuntu) you could also use kaffeine to play your multimedia files. In order to do so you need to edit the .kde/share/apps/kaffeine/xine-config file in your home directory. Find the 'audio.driver' parameter and change it to 'alsa'. You also need to change the 'audio.device.alsa_front_device' parameter and change it to 'a2dpd'.

There's a bit of delay between the picture and the voice but it's bearable for me.

Configure Ekiga

Due to the lack of proper sound devices enumeration scheme in current ALSA architecture, Ekiga is unable detect peripherals that are not seen by the system as hardware cards. This means Ekiga is unable to let you choose your bluetooth headset in the list. To workaround this issue a patch is provided for Ekiga (see patches directory), that should be applied to the pwlib library.

Configure SCO (aka mono, aka voice) Driver

This driver will let you do 2-way audio to and from a mono headset. It's called SCO because the transport is Synchronous Connection-Oriented to guarantee low latency.

The old method involves a kernel module and the btsco daemon. See below for the details for this method.

The preferred method uses an outstanding alsa plugin written by Fabien Chevalier instead and requires no kernel patches nor modules. The plugin was installed when you performed the plugz install above.

If you base your .asoundrc on the example alsa-plugins/asound.conf from the plugz cvs module, you can edit it to use your SCO headset address. Then change the alsa device in xmms to headset and run /usr/bin/headsetd. You should be able to use the headset at this point.

If you subsequently change your .asoundrc, you will have to restart xmms but you don't need to restart headsetd.

You will have to set your applications to use the alsa device headset similar to what we did above with a2dpd. Unfortunately some applications won't let you choose this device because they won't let you type in the name of the device and they don't use the extended alsa api for finding alsa plugin devices. At least in the case of vlc, you can edit its configuration directly to get around this.

BIG FAT WARNING: You will crash your box if you don't have a kernel patch applied. This is due to a bug in the kernel that is not yet fixed at the time of this writing. This patch is called the 'SCO flow control patch', and can be found in the patch/ directory of the plugz project or here. This patch should apply to any recent (2.6.18+) Linux kernel.

Using mplayer with SCO

The device syntax is: -ao alsa:device=headset

Using twinkle for voip

Twinkle reports an error "Critical: Opening ALSA driver failed: snd_pcm_hw_params_set_rate(8287) failed: Invalid argument" but it works anyway. There is probably some stuff you could add to asound.conf or .asoundrc that would allow for the rate change to succeed and avoid the warning.

Using kphone

Currently kphone does not work with headsetd. (Kphone tries to set the number of output channels to 2 but the alsa plugin only advertises 1.)


See the contact section.

Legacy drivers

If for some reason you need to try the old driver, instead of checking out "plugz" above, check out "btsco" and build it the same way.

For the old kernel mod + btsco architecture, you need a kernel with the emu10k1 driver selected (this is one of the drivers that forces the inclusion of the implementation of "snd_hwdep_new"). Build the kernel module:

	cd kernel
	make install
	depmod -e
	make clean
  1. insert the module (or better, set up the alsa configuration to load it)
    	modprobe snd_bt_sco
  2. stop the esound controller if it's running via
    	esdctl stop
  3. run
            hciconfig hci0 voice 0x0060
  4. turn on the headset (you may need to prepare the headset to be paired the computer, usually by turning on the headset and holding the on button until it beeps; make sure the headset has not connected to your cell--this would block the computer's connection.)
  5. run the handler (let it keep running if you run in the foreground)
    	btsco bdaddress
  6. You probably need to enter the passkey if it's the first time 'round
  7. send and receive audio from the headset (usually using /dev/dsp1) or via the alsa device with something like
    	aplay -B 1000000 -D plughw:Headset sound.wav
Right now the daemon interaction is somewhat limited: Andreas Beck contributed a .btscorc and skype script for making the headset button answer an incoming call. It's in our contrib/ dir and he may have updates here.

Legacy Stereo (A2DP) Testing

Only developers should need to use this testing code. The A2DP plugin work is mature enough to use directly.

A2DP provides a way to send stereo high-quality audio to some of the newer headsets. On all the headsets I've seen so far, this is one-way audio, so if you were expecting to get something like a gaming headset (talking to other players, getting stereo sound back from the game), you should wait for the next generation of headsets to get 2-way A2DP.

This code is found only in the "btsco" package.

To test stereo audio without installing the alsa plugin, you can run:

	mpg123 --au - file.mp3 | ./a2play 00:0D:3C:30:32:AD
Where you replace file.mp3 with a good mp3 file and bdaddr with the address of your headset. You can send live audio from line-in etc using a command like:
	./a2play -s -d -r 44100 00:0D:3C:30:32:AD /dev/dsp
Don't be surprised to get a delay. It's probably under 500ms but not much under that.

The A2DP sink code receives a stream from another device. Run it with:

        hciconfig hci0 class 0x200404
	sdptool add A2SNK
It will try to bind to the bluetooth adapter and send audio out to /dev/dsp.

Embedded status

The status of work on gumstix/xscale is on its own page.