The thoughts of a Systems and Network Administrator and computer geek on networking, computers, and life.

Wednesday, 7 March 2012

Call for testing: BlueZ A2DP and HSP/HFP profiles

We just landed bluez 4.98-2ubuntu2 in Precise. The key change was to enable the Source and Gateway profiles by default, which will now allow people to use their system as an audio output device. It works great on Android, but any help in testing this on a bunch of different devices (especially on iPhone) would be much appreciated!

The Source profile is what enables the A2DP bluetooth profile. With it, you can use your system as a stereo audio output device: in other words, you can send output audio from an external device such as a phone or a tablet to your computer (though this will require a bit of work on the PulseAudio side to get the audio stream to go through the right devices).

There's the AskUbuntu question "Can I use my computer as an A2DP receiver?" that describes the steps to use this right now. Thanks to Steve Langasek for figuring out the details. I've also written a draft script that implements the suggested steps and makes it simple:

That script is meant to be called as '"whatever_you_named_it" enable'. Don't forget the "enable" part, or "disable" to turn off the streams, otherwise it won't work.

The Gateway profile enables the HSP/HFP bluetooth profiles. This means we're getting closer to supporting phone calls from a bluetooth-connected phone on a Ubuntu computer. There's already some amounts of support for this via Ofono and the telepathy-ring project, although there is some extra work needed -- hopefully we can fix this by the Precise release. :D

The way I'd verify this would be to file a bug on Launchpad, and include the debugging logs from pulseaudio before pairing the device (or enabling the connection, really); which is done by sending the "set-log-level 4" command in pacmd (then the logs will appear in /var/log/syslog); and debugging logs from bluez (sudo stop bluetooth && /usr/sbin/bluetoothd -n -d).

hi! could you please provide a bit more info on how to test this on android, I've tried by changing my audio.conf but it seems like I'm missing something else, perhaps something like what you are doing with pulse here but doing it with audioflinger?

I have streaming from android (ideos U8150)working quite well, though i had to hack a little by editing the file:"/system/etc/bluetooth/audio.conf" on the android system which required read-write "rw" remount of the system using the command:"mount -o rw,remount -t yaffs2 /dev/block/mtdblock4 /system"where "/dev/block/mtdblock4" and "/system" was figured out using the command " cat /proc/mounts" as the system and mount point(install and use a terminal app on android for checking using cat and remounting, and also changing the permissions of the file so its editable using "chmod permissions /path_to_file"). that file contains a section for enabling audio Headset, Control, source and sink, its well documented. All you gotta do is pull it to PC using "adb pull /system/etc/bluetooth/audio.conf ~/audio.conf" and edit the file ~/audio.conf accordingly, save and do "adb push ~/audio.conf /system/etc/bluetooth/audio.conf"(this uses phone debug via usb cable)and switch bleutooth off, then on, on the phone. then use blueman applet on precise to pair, list services and connect to your phone. Also you have to make your phone ubuntu bluetooth discoverable, basic steps... and use pulseaudio volume controller to select audio source. just click on ua phone if listed, if not use the drop-down menu on pulseaudio to select "show all" under sources. Thats all.

Any clues on integrating A2DP sink feature on Android mobile devices using the Bluez capabilities. I mean to use ANdroid phone to behave like a BT headset to play music from some other devices like PC or another smart phone?