Thursday 26 July 2012

Bluetooth headphones in linux

I obtained a relatively cheap pair of 'laser' bluetooth headphones today. It's lightweight, colorful, has a built in mic for calls and claims to have up to 10 hours of play time. But best of all it accomplishes all this without wires.

Getting this to work with android 2.3 was easy enough. During pairing just hold the power switch for 6 seconds. You hear a cute little tone and off you go.

To get this to work in slackware 13.37 required a little bit more work, but not much.

The steps to make it work were:

1) charge up the headphones until the light turns blue

2) in linux, start bluetoothd:
#/usr/sbin/bluetoothd

3) run blueman-manager
$ blueman-manager

4) make sure the device is on then hit search, if everything is configured okay then the headset device should appear

5) start the pairing process and hold the power switch for 6 seconds

6) after it has successfully paired it may still not be connected, so hit the trust button to trust the device

7) then run the 'Setup' on the device and choose A2DP Sink (Send Audio)

8) right click on the device and the option for 'audio sink' should appear. click on that to enable sending audio to the device. now leave blueman-manager open for the next step...

9) now, as root, edit /etc/asound.conf by adding the lines below. Make sure to substitute the XX:XX.. numbers with the address of the device which is visible in the blueman-manager window.

you may also replace pcm.btheadset with pcm.!default if you wish to make it the default device. alsa will need to be restarted with # /etc/rc.d/rc.alsa restart or similar

# /etc/asound.conf

pcm.btheadset {
   type plug
   slave {
       pcm {
           type bluetooth
           device XX:XX:XX:XX:XX:XX 
           profile "auto"
       }   
   }   
   hint {
       show on
       description "BT Headset"
   }   
}
ctl.btheadset {
  type bluetooth
} 


 
10) Save the file then type $ aplay -L to check the btheadset device is recognized

11) run mplayer or player of your choice with the device set to btheadset..

$ mplayer -ao alsa:device=btheadset ~/miku-hatsune-i-wanna-be-your-world.mp3


You might be wondering how do they sound? To be honest they sound a lot better than what I was expecting.


References:
https://wiki.archlinux.org/index.php/Bluetooth_Headset#Headset_and_Alsa_Devices