Sign In

    Enjoy FOSSwire's content? Have it delivered! Subscribe

    PulseAudio Bluez

    Some time ago, I’ve shown different methods of using scripts and configuration files to get Bluetooth A2DP audio working properly. But that’s a problem: it requires setup. Ideally this should all happen automatically right when the headphones are paired.

    In the latest releases of PulseAudio and Bluez, I found this to be the case. It works so well that I figured I’d make a screencast out of it just to show you. The application used in the video is pavucontrol, the volume controls for PulseAudio.

    (And a sidenote: this video was edited using PiTiVi, which just made a new release. I highly recommend you check it out.)


    Opening Up Video on the Web - Is it Possible?

    Film strip image - by dpade1337 on Flickr

    The web works because of open standards. It doesn't matter whether you're reading this on a Firefox on Linux, Opera Mini on a BlackBerry, IE on Windows, or even (possibly with a few issues) WorldWideWeb on NEXTSTEP. You can still read this content, because all of the protocols and languages used to encode and deliver this content to you are open standards.

    For text and images, this pretty much works. Video, on the other hand, is a much more challenging issue. There are lots of competing ways to encode and deliver video on the web, some of which are available under open licences (say, Ogg Theora) and some of which are not (Flash video). And, unfortunately, the open ways to do it aren't the most popular right now and don't have much out-of-the-box support beyond open source operating systems.

    Mozilla recently announced that they are putting $100,000 behind the Wikimedia Foundation to push the Theora video codec, which is free and open. Support for the Theora codec will also be built right into Firefox 3.1, which should make it easier to distribute content encoded with it, without users having to install special software.

    That's great. But are we already too late to push for open video standards, with proprietary platforms and FOSS-incompatible standards already reaching ubiquity?

    Companies like Microsoft, Apple and Adobe are unlikely to want to standardise on something else, when they already have made investments elsewhere. Apple, for example, has put huge weight behind the MPEG-4 platform, particularly the H.264 video and AAC audio codecs and it would seem very unlikely that they would then invest in any other platform.

    Now this MPEG-4 stuff is an ISO standard; we are even reaching a certain degree of convergence across traditional tech companies. I can take an H.264/AAC movie and play it on an Xbox 360 or an Apple TV and it all works exactly the same.

    So why can't free software play nice with this MPEG-4 stuff? It's an ISO standard, right? The problem is that the codecs that make up MPEG-4 are often subject to patents and other intellectual property restrictions that leave open source and free software out in the cold. The potential threat of legal action means that while support might exist, it is challenging to bundle and a bit of a grey area.

    The free software community aren't able to participate in any standard video and audio formats unless these standards are actually going to work within their licensing frameworks and not be embroiled in IP soup.

    So, free software becomes less of a viable platform if it simply can't do this out of the box. This means that it either won't grow very much and spread the greater good (if you will), or we have to make sacrifices about the 'purity' of our software, which is more palatable to some than others.

    Theora logo

    Does it then make sense for us to make our own formats, Theora, for example, and try to push them to compete with the existing ones? Or, does this just make the whole codec mess more, well, messy? The pragmatist in me doesn't think this competition approach makes an awful lot of sense. I'd be perfectly happy to compromise and just run with the MPEG formats, however imperfect.

    Don't get me wrong, though - I think having a video format suitable for the FOSS world which works on FOSS out-of-the-box is vitally important. It's just that this makes it a real challenge for content providers actually support both free software users and, well, everyone else that doesn't ship that stuff. Two versions of the same content? It's too difficult unless a big part of your audience are using pure FOSS, so it's not considered worth doing.

    We're in a bit of a deadlock situation. Maybe I'm cynical, but it feels like the goal of having a truly open web, for all the content available on it, is an impossible one. At least, that is, until some major change comes around and our community get to have a share of the influence on the next big standard.

    Oh, and when US intellectual property law gets a bit more sensible.

    What do you think about open standards on the web? Is this goal of everything being in an open format achievable, now or in the future? Share your thoughts in the comments.

    Film strip image at top of post is by dpade1337 on Flickr, licensed under Creative Commons BY-SA. The Xiph Fish Logo and its theora.org variant are trademarks of Xiph.Org.


    Better Bluetooth Audio

    Earlier this year, I showed you how to get high-quality A2DP audio streaming to your Bluetooth headphones. And while that method of connecting your headphones to a music player does work fine, it really only works with media players and anything else set up to specifically play to your headset. What if you want to watch a Flash video with A2DP audio? How about play a game of Nexuiz through the headset? Well, with that implementation, you can't.

    And next week, with the release of Ubuntu 8.10, that method will not even work anymore due to a new incompatible version of Bluez. But on the flipside, we really don't even need to do that anymore.

    Most distributions include a somewhat recent version of PulseAudio. Love it or hate it, it becomes an excellent tool for the job. Using PulseAudio sinks (outputs), we are able to create a new device visible for Pulse to play to. This means not only your music player, but also your games, websites, and everything else, can play through your wireless headset.

    Note: If you used any of the instructions from the previous article, undo them entirely. First make sure your GStreamer output is set back to speaker mode if you used it. Then, delete the .a2dp folder in your home directory. Finally, remove the A2DP Connection script from System > Preferences > Sessions. Leaving anything laying around could interfere with the new process.

    Also note that these are merely some things to try out. They are by no means complete; real, full Bluetooth support will come in a later PulseAudio release. PulseAudio 0.9.13 includes the start of this work, but it isn't too use-friendly at the moment.

    Let's get started. Open up the file .asoundrc in your home directory (create it if you can't find it), and change its contents to something like this:
    pcm.bluetooth {
    type bluetooth
    device "00:00:00:00:00:00"
    }

    Replace the device line with the MAC address of your headphones. To find the MAC address, put the headset in pairing mode, and run hcitool scan. Also, if you headphones aren't already paired with your computer, do that now using the Bluetooth applet in the notification area.

    Save that file and log out and back in again to make ALSA re-read the configuration. Now we can set up PulseAudio with a simple one-liner:

    pactl load-module module-alsa-sink device="bluetooth"

    Be sure your headphones are on. When you see a number appear on the command line, they are ready. Pulse will automatically turn on and off the headphones as needed when it wants to play sound. Caveat: You cannot set this to run at startup, as it will sometimes fail. You can, however, add it as a panel launcher and enable your headphones with a single click.

    Now go ahead and open up Rhythmbox or another music player (or something else you know uses PulseAudio) and play a track. If you don't get any audio, check to make sure your headphones are on and paired properly, and try the above command again. If the audio still comes out of your speakers, then you will want to re-route the audio.

    To do this, install the pavucontrol (PulseAudio Volume Control) application, which may be present on some distributions already. Open it up, and go to the Output Devices tab. Find your headset in the list (labeled "bluetooth") and click the down arrow on the right. Check Default, and try playing audio again. If it still comes out of the speakers, then Pulse is remembering previous settings. Leave the music playing, and go to the Playback tab. Click the down arrow next to the active stream (probably labeled as your music player and current song) and select Move To and then "bluetooth". Wait a moment, and the audio should then route to the headphones. From that point on, Pulse should remember that it should always play to your headphones for that application if they are available.

    Feel free to experiment with different setups to find out what works best for you. If things don't work out the first time, simply keep trying. Share your findings in the comments below.

    Bonus tip: AVRCP


    Just like in the last article, you can enable AVRCP (play/next button) support by adding uinput to the end of /etc/modules. Reboot and your headphones should work!


    1. 1
    2. 2
    3. 3