Linux bluetooth audio: using alsa and a2dp

I got a pair of bluetooth headphones for Christmas, and they have made listening to music so much easier. The model is Zoom 4380. I used them with my phone, and the absence of wires from the phone (and the little drop-down speaker stalk) makes calling cool too.

The only problem I have atm is resuming music from the headphones, once it has stopped.

Anyway, the purpose of this thing here is using these headphones with Gentoo. In the end, the setup seemed easy. The journey wasn’t…

Simple steps:

  1. Get alsa working. See the gentoo howto here
  2. Get normal bluetooth working: here. I needed to make bluez-utils with the “test-programs” USE flag, so passkey-agent is built.
  3. Get the address for the headphones. Use the command

    hcitool scan

  4. Create a local alsa settings file, ~/.asoundrc. The XX:XX.. should be replaced with address you found in the last step.

    pcm.bluetooth {
    type bluetooth
    device XX:XX:XX:XX:XX:XX
    profile “auto”

  5. The main problem I had for quite a while was getting the pin into system, when you start playing a file. Eventually, I tried the following passkey-agent line:

    passkey-agent –default 0000 XX:XX:XX:XX:XX:XX

    The XX:XX.. is the address from above, again. The 0000 is the pin for the headphones. You don’t have to run this as root.

  6. Finally, play something. I use mplayer for mp3 and videos, so here is a command line I used:

    mplayer -ao alsa:device=bluetooth <mp3 file>

    You should hear your music in your headphones.

  7. See here for a much more complete list of supported players using this method.


Leave a Reply

Your email address will not be published. Required fields are marked *