Tag Archives: pulseaudio

Bluetooth Workshop at the Kernel Summit

Yesterday and today I’ve got the opportunity to attend the Bluetooth workshop, which is part of the Linux Kernel Summit. During the two days a lot of topics have been discussed, with highlights for the release of BlueZ 5, which will finally remove all the API marked as deprecated but still laying around. This includes the unix api, which means applications which dont yet use the D-Bus fd-passing API will have to upgrade it. Now.

Another important removal will be the ALSA modules for A2DP and HSP. I know some people still using it, despite the fact that PulseAudio bluetooth support is around for about 4 years now and its the recommended way to use both profiles. So now it’s serious, upgrade your installation or you are on your own from now. The gstreamer support will still remain on the tree but still, the recommended way to use these profiles is through PulseAudio.

Also a lot of discussion happened over the LE profiles (which are part of the Bluetooth 4.0 spec) and how to correctly add support for them in the right way and well integrated with the current BR/EDR profiles. There were also discussions on the AMP support and the MGMT interface, which will help to add support for that.

Finally we had an audio discussion together with some of the PulseAudio main hackers (Colin and Arun), which were around for the gstreamer conference.

I would like to thank the Linux Foundation for helping me attending this event. Seriously, you rock!

Desktop Summit and Linux Plumbers

The last couple of months have been very busy with regards to travelling (among other things I may, or may not, write about in upcoming posts), and because of that I’ve been really away from teh interwebs.

First of all I’ve got the opportunity to attend the really amazing Desktop Summit in Berlin. There I met a lot of very nice and interesting people, with highlights to Will Thompson (Collabora), who have been helping me on the OTR project on Telepathy; Lennart Poettering (Red Hat), who I’ve worked with in the past, when writing the PulseAudio bluetooth modules; Colin Guthrie, current PulseAudio maintainer, and lots of other very cool and smart people that were around there. I’ve also met some old friends from university who are now working at INdT, and other not-that-old friends from the GNOME community.

Besides all the networking and good talk on the hallways and social events (which were amazing, BTW), I had the awesome experience to help the conference organization as a volunteer, and highly recommend that. Not only because I got to meet a lot of cool people, or because I really felt well helping to build up this amazing conference. Also because it was very very fun, and I’m looking forward for this opportunity again next year (if I managed to attend 2012 GUADEC). I’ve also gave a lightning talk on my Telepathy OTR work, and surprisingly got a big applause from someone I couldn’t spot on the audience. Many thanks for that! 🙂

After that I’ve spent one more week in Europe, than back home for a couple of days, and than amazing sand dunes in a place called “Lençóis Maranhenses” with my girlfriend, on the NE of Brazil. And while there, I got an email from Lennart saying that my talk to the Linux Plumbers Conference was accepted! Yay! So I run to look for flights and about 1 week later I was flying to SFO to attend the LPC in Santa Rosa.

The LPC is very different from the Desktop Summit, beginning from its size: about 300 people, comparing to 800 on the DS. Additionally, most sessions on the LPC are very very technical, with a lot of discussion during the sessions. Also, there is much less sense of “we’re a community” if compared to the DS, probably because most projects are much smaller than the big window managers.

All the talks I’ve attended on the LPC were very good, and I had quick chats to a lot of different people between sessions. I’ve met better with Arun Raghavan (Collabora), which I was introduced to in the DS and is also one of the PulseAudio hackers; and also met Pierre-Louis Bossart (Intel), and experienced audio engineer whom I’ve exchanged emails about his module-loopback on pulse about 3 years ago, by the time I wrote the A2DP sink.

My talk about AVRCP on the Audio track of the LPC went all good, and I got some nice feedback on how to get the Linux desktop to be AVRCP 1.4 compliant. Stay tuned to read more on that in the future. And I also need to congrats the LPC organizing committee for such a great conference and awesome social events and catering during the event. On the last night I’ve meet with Jamey Sharp (Apters), XCB developer, and we had a really nice chat about travelling, e-book readers and so on.

After the event, I spent 3 really cool days in San Francisco with my friend Bruno Cardoso. Thanks for the good time, bro!

And last but definitely not least, I want to say big thanks for both the GNOME Foundation, for sponsoring my trip to the Desktop Summit, and the Linux Foundation, for sponsoring my trip to the Linux Plumbers Conference.

Handsfree HF role

Here at ProFUSION we’ve been helping people at BlueZ, oFono, and PulseAudio to add support for the Handsfree-unit role of the bluetooth Handsfree Profile to Linux. We had some nice progress this week that lead us to make a video showing what we have so far. It’s still not merged upstream, and definitely not user friendly. But hey, it works!

Kudos to Gustavo Padovan for implementing most of this support into BlueZ and oFono.

1, 2, 3, 4, A2DP Stream

After a few people asking me how to use the A2DP Sink with BlueZ, I’ve decided to write this mini-tutorial with a step-by-step on how to establish a A2DP stream from any device to a BlueZ-enabled host.

Before we start the hands-on, let’s see a little bit of nomenclature. In our use-case we have an stream being transmitted between two devices through a pipeline. Our pipeline is constructed of the remote host, BlueZ and PulseAudio. Each element of this pipeline has a Source (SRC) and a Sink (SNK) interface. The stream is handled between different elements by being sent from one element’s source to another element’s sink. So, the big picture of our pipeline is something like this (with the stream being represented by an arrow):

Remote-SRC ----> SNK-BlueZ-SRC ----> SNK-PulseAudioBT-SRC

With the PulseAudio bluetooth source being available for applications to connect to it and serve themselves with fresh, just-decoded PCM frames of pure stereo audio. In our example, we gonna add another element to the pipeline tho. In order to able to hear the audio we’re receiving, we gonna connect the PulseAudio bluetooth source to a PulseAudio ALSA sink which pushes the audio out through our soundcard speakers.

PulseAudioBT-SRC ----> SNK-PulseAudioALSA ----> SoundCard

So after these lines on theory, let’s get out hands dirty. First of all, you need a recent version of BlueZ and PulseAudio. BlueZ 4.46 and PulseAudio 0.9.16 should be enough, but I strongly recommend getting the newest releases available by the time you read this. Right now the most recent releases are BlueZ 4.58 and PulseAudio 0.9.21.

  1. PulseAudio must be running with module-bluetooth-discover loaded;
    • This module is automatically loaded on startup with the default configuration;
    • If it’s not loaded you can use pactl to load it manually or configure PulseAudio to load it on startup in /etc/pulse/default.pa;
  2. Enable the Source interface on BlueZ:
    • edit /etc/bluetooth/audio.conf and add the following line: Enable=Source ;
    • restart bluetoothd;
  3. Pair both devices;
  4. On the object path representing the remote host, on org.bluez D-Bus service, call the org.bluez.AudioSource.Connect() method;
    • For the connection to succeed you’ll probably have to grant access on the remote host;
    • When the connection is established, a new card should show up on PulseAudio with one source available;
  5. Connect PulseAudio bluetooth source to PulseAudio ALSA sink;
    • load-module module-loopback source=<name> sink=<name>
    • You can use the line above to load the module-loopback, using pactl (on the command line) or inside pacmd shell;
    • To find out the name of the source and the sink, you can use the commands list-sources and list-sinks inside pacmd shell;
    • This step is only needed if you want to send the audio coming through A2DP to your speakers.

It’s important to remember that the current implementation is working but could see some improvements, so expect to hear some glitches if you go through signal variation. Happy bluetooth audio streaming!

Bluez-PulseAudio is now mainstream

With the PulseAudio 0.9.13 being release on Oct 10th, my bluetooth module for PulseAudio has gone upstream! Check out the relese notes.

Com o lançamento do PulseAudio 0.9.13 em 10/Oct, meu módulo bluetooth entrou na linha de desenvolvimento principal! Veja as notas de lançamento.

Con el lanzamiento del PulseAudio 0.9.13 en 10/Oct, mi modulo bluetooth ha entrado en la linea de desarrollo principal! Vea las notas de lanzamiento.

GSoC 2008

This year I’ve participated in the Google Summer of Code program. Despite the fact that wasn’t summer in the southern hemisphere, everything happened as expected. I’ve worked with BlueZ as my mentoring organization, and my project was to add bluetooth support to the PulseAudio sound server. The abstract of my application can be found here.

The implementation was made through 2 modules: module-bluetooth-device and module-bluetooth-discover. The latter connects to BlueZ through D-Bus to find out what devices have already been paired with each adapter present on the system, and the loads one instance of the module-bluetooth-device for each device found (in contrast to linux kernel modules, PulseAudio modules can be loaded more than once at the same time). It also keeps watching for new adapters and devices, so it can load a module to take care of each new device that shows up.

The former, module-bluetooth-device, is the one who actually does the job of creating the bluetooth audio channel in PulseAudio. First, it connects to the BlueZ audio service through one unix socket to obtain the device capabilities. Then it configures the device according to it’s capabilities, setup the SBC encoder (if applicable) and obtain a file descriptor to write audio data to the device. This fd is passed to a PulseAudio I/O thread (which runs with real time priorities if the user has real time privileges properly set), which gets the audio data coming to this sink (sink is the name of an output channel in PulseAudio), encode it (if applicable) and write it on the device fd. Also, the I/O thread has to take care of the clock synchronization between PulseAudio an the device.

I really enjoyed doing this job. Working with an open source community is outstanding! I’ve learned a lot during the program, made good contacts, and the most important: had a lot of fun! I would like to thank a lot my mentor, Luiz Augusto von Dentz, and the PulseAudio maintainer, Lennart Poettering. Without the help of these two guys I wouldn’t have been able to finish this project. And of course I have to thank Google for helping FLOSS develpment throug this program and LH for making the program happen and for being so kind and patient with all the students. LH, you rock!

I’ll continue working on this project, since there still a lot to be done. Time synchronization is not the best and the usability is far from ideal. I have a git repository for this on gitorious, on an branch called bt. Feel free to point bugs and make sugestions. Also, if you really enjoyed the project and want to help more, I accept donations of A2DP, HSP, or HFP bluetooth audio devices, for test and development. All of this was made so far with a borrowed device from my good friend João Eduardo Ferreira Bertacchi (thanks JE!). The oficial release note on the BlueZ website about this project can be found here.