Sunday, January 22, 2012

Blog moved

I have moved the blog over to a self-hosted wordpress site: http://lazybottom.snowglo.be. Please update your subscriptions accordingly if you are still interested ;-)

Saturday, January 21, 2012

Bluetooth + pulseaudio misery on Ubuntu Precise

During one of the usual apt-get dist-upgrade cycles I have noticed that my bluetooth speakers no longer work. I decided to spend some time debugging the issue today.

It was weird because the speakers were definitely paired to my notebook as I could see the blue light on them. That usually means an active connection between the speakers and something. First thing to check: 

zsol@urgar-ubuntu:~$ hcitool con
Connections:
    < ACL 00:02:3C:25:C0:A2 handle 12 state 1 lm SLAVE AUTH ENCRYPT
zsol@urgar-ubuntu:~$ hcitool name 00:02:3C:25:C0:A2
Creative T12 Wireless

Yep, speakers are definitely there. So why are they not showing up in any mixer application I tried? I vaguely remembered the label they usually get: Playback: Creative T12 Wireless (PulseAudio Mixer). Aha! Must be something with pulseaudio. Back in the day I used to fiddle around a lot with the pulseaudio settings (when Ubuntu first introduced it) and I have read quite a huge amount of back-and-forth flamewars between Ubuntu/Pulseaudio developers which illustrated the huge gap between their idea of a general purpose audio subsystem. It must be something with pulseaudio and Ubuntu again! :-)

Sure enough, killing pulseaudio and rerunning it from a console with debug logging showed this:

bt_audio_service_open: connect() failed: Connection refused (111)
W: [pulseaudio] module-bluetooth-device.c: Bluetooth audio service not available
W: [pulseaudio] module-bluetooth-device.c: Service not connected
I: [pulseaudio] card.c: Freed 4 "bluez_card.00_02_3C_25_C0_A2"
E: [pulseaudio] module.c: Failed to load module "module-bluetooth-device" (argument: "address=00:02:3C:25:C0:A2"): initialization failed.

After stracing through pulseaudio, it turned out that it was trying to connect to a socket that did not in fact exist. At this point I spent a considerable amount of time searching for documentation on the exact options in the files under /etc/bluetooth/*.conf but all my efforts were in vain. Eventually, after stepping back a few times and getting more and more desperate, I found this gentoo wiki entry which described the exact same symptoms as I had, and offered the magic configuration option - put this in /etc/bluetooth/audio.conf under the [General] section:

Enable=Socket

After restarting the bluetooth stack, everything started working - the socket has been created, pulseaudio picked it up and finally my speakers were available in all of my mixers; including pavucontrol/paman.