<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Arun Raghavan &#187; collabora</title>
	<atom:link href="http://arunraghavan.net/tag/collabora/feed/" rel="self" type="application/rss+xml" />
	<link>http://arunraghavan.net</link>
	<description>Extremely pithy tagline here</description>
	<lastBuildDate>Tue, 17 Jan 2012 07:54:54 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<item>
		<title>PulseAudio vs. AudioFlinger: Fight!</title>
		<link>http://arunraghavan.net/2012/01/pulseaudio-vs-audioflinger-fight/</link>
		<comments>http://arunraghavan.net/2012/01/pulseaudio-vs-audioflinger-fight/#comments</comments>
		<pubDate>Mon, 16 Jan 2012 12:22:30 +0000</pubDate>
		<dc:creator>Arun</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[collabora]]></category>
		<category><![CDATA[f/oss]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[pulseaudio]]></category>
		<category><![CDATA[work]]></category>

		<guid isPermaLink="false">http://arunraghavan.net/?p=1189</guid>
		<description><![CDATA[I&#8217;ve been meaning to try this for a while, and we&#8217;ve heard a number of requests from the community as well. Recently, I got some time here at Collabora to give it a go &#8212; that is, to get PulseAudio running on an Android device and see how it compares with Android&#8217;s AudioFlinger. The Contenders [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been meaning to try this for a while, and we&#8217;ve heard a number of requests from the community as well. Recently, I got some time here at <a href="http://www.collabora.com/projects/pulseaudio">Collabora</a> to give it a go &#8212; that is, to get PulseAudio running on an Android device and see how it compares with Android&#8217;s AudioFlinger.</p>

<h2>The Contenders</h2>

<p>Let&#8217;s introduce our contenders first. For those who don&#8217;t know, <a href="http://pulseaudio.org/">PulseAudio</a> is pretty much a de-facto standard part of the Linux audio stack. It sits on top of <acronym title="Advanced Linux Sound Architecture">ALSA</acronym> which provides a unified way to talk to the audio hardware and provides a number of handy features that are useful on desktops and embedded devices. I won&#8217;t rehash all of these, but this includes a nice modular framework, a bunch of power saving features, flexible routing, and lots more. PulseAudio runs as a daemon, and clients usually use the <tt>libpulse</tt> library to communicate with it.</p>

<p>In the other corner, we have Android&#8217;s native audio system &#8212; AudioFlinger. AudioFlinger was written from scratch for Android. It provides an API for playback/recording as well as a control mechanism for implementing policy. It does not depend on ALSA, but instead allows for a sort of <acronym title="Hardware Abstraction Layer">HAL</acronym> that vendors can implement any way they choose. Applications generally play audio via layers built on top of AudioFlinger. Even if you write a native application, it would use <a href="http://www.khronos.org/opensles/">OpenSL ES</a> implementation which goes through AudioFlinger. The actual service runs as a thread of the <tt>mediaserver</tt> daemon, but this is merely an implementation detail.</p>

<p><em>Note: all my comments about AudioFlinger and Android in general are based on documentation and code for Android 4.0 (Ice Cream Sandwich).</em></p>

<h2>The Arena</h2>

<p>My test-bed for the tests was the <a href="http://en.wikipedia.org/wiki/Galaxy_Nexus">Galaxy Nexus</a> running Android 4.0 which we shall just abbreviate to ICS. I picked ICS since it is the current platform on which Google is building, and hopefully represents the latest and greatest in AudioFlinger development. The Galaxy Nexus runs a Texas Instruments OMAP4 processor, which is also really convenient since this chip has pretty good support for running stock Linux (read on to see how useful this was).</p>

<h2>Preparations</h2>

<p>The first step in getting PulseAudio on Android was deciding between using the Android <acronym title="Native Development Kit">NDK</acronym> like a regular application or integrate into the base Android system. I chose the latter &#8212; even though this was a little more work initially, it made more sense in the long run since PulseAudio really belongs to the base-system.</p>

<p>The next task was to get the required dependencies ported to Android. Fortunately, a lot of the ground work for this was already done by some of the awesome folks at Collabora. Derek Foreman&#8217;s <a href="http://cgit.collabora.com/git/user/derek/androgenizer.git/"><tt>androgenizer</tt></a> tool is incredibly handy for converting an <tt>autotools</tt>-based build to Android&#8211;friendly makefiles. With Reynaldo Verdejo and Alessandro Decina&#8217;s prior work on <a href="http://gstreamer.freedesktop.org/modules/gst-android.html">GStreamer for Android</a> as a reference, things got even easier.</p>

<p>The most painful bit was <tt>libltdl</tt>, which we use for dynamically loading modules. Once this was done, the other dependencies were quite straightforward to port over. As a bonus, the Android source already ships an optimised version of Speex which we use for resampling, and it was easy to reuse this as well.</p>

<p>As I mentioned earlier, vendors can choose how they implement their audio abstraction layer. On the Galaxy Nexus, this is built on top of standard ALSA drivers, and the HAL talks to the drivers via a minimalist <a href="https://github.com/tinyalsa">tinyalsa</a> library. My first hope was to use this, but there was a whole bunch of functions missing that PulseAudio needed. The next approach was to use <a href="http://www.alsa-project.org/main/index.php/SALSA-Library">salsa-lib</a>, which is a stripped down version of the ALSA library written for embedded devices. This too had some missing functions, but these were fewer and easy to implement (and are now <a href="http://git.kernel.org/?p=linux/kernel/git/tiwai/salsa-lib.git;a=commit;h=8485a2bdc725b531794f277cd3e37973a8524830">upstream</a>).</p>

<p>Now if only life were that simple. :) I got PulseAudio running on the Galaxy Nexus with <tt>salsa-lib</tt>, and even got sound out of the HDMI port. Nothing from the speakers though (they&#8217;re driven by a TI <a href="http://www.ti.com/product/twl6040">twl6040</a> codec). Just to verify, I decided to port the full <tt>alsa-lib</tt> and <tt>alsa-utils</tt> packages to debug what&#8217;s happening (by this time, I&#8217;m familiar enough with <tt>androgenizer</tt> for all this to be a breeze). Still no luck. Finally, with some pointers from the kind folks at TI (thanks Liam!), I got current <acronym title="Use Case Manager">UCM</acronym> configuration files for OMAP4 boards, and some work-in-progress patches to add UCM support to PulseAudio, and after a couple of minor fixes, wham! We have output. :)</p>

<p><em>(For those who don&#8217;t know about UCM &#8212; embedded chips are quite different from desktops and expose a huge amount of functionality via ALSA mixer controls. UCM is an effort to have a standard, meaningful way for applications and users to use these.)</em></p>

<p>In production, it might be handy to write light-weight UCM support for <tt>salsa-lib</tt> or just convert the UCM configuration into PulseAudio path/profile configuration (bonus points if it&#8217;s an automated tool). For our purposes, though, just using <tt>alsa-lib</tt> is good enough.</p>

<p>To make the comparison fair, I wrote a simple test program that reads raw PCM S16LE data from a file and plays it via the <tt>AudioTrack</tt> interface provided by AudioFlinger or the PulseAudio <a href="http://freedesktop.org/software/pulseaudio/doxygen/async.html">Asynchronous API</a>. Tests were run with the brightness fixed, wifi off, and USB port connected to my laptop (for adb shell access).</p>

<p>All tests were run with the CPU frequency pegged at 350 MHz and with 44.1 and 48 kHz samples. Five readings were recorded, and the median value was finally taken.</p>

<h2>Round 1: CPU</h2>

<p>First, let&#8217;s take a look at how the two compare in terms of CPU usage. The numbers below are the percentage CPU usage taken as the sum of all threads of the audio server process and the audio thread in the client application using <tt>top</tt> (which is why the granularity is limited to an integer percentage).</p>

<table>
<colgroup span="2"/>
<colgroup span="2"/>
<tr> <th colspan="2">44.1 kHz</th> <th colspan="2">48 kHz</th> </tr>
<tr> <th>AF</th> <th>PA</th> <th>AF</th> <th>PA</th> </tr>
<tr> <td>1%</td> <td>1%</td> <td>2%</td> <td>0%</td> </tr>
</table>

<p>At 44.1 kHz, the two are essentially the same. Both cases are causing resampling to occur (the native sample rate for the device is 48 kHz). Resampling is done using the Speex library, and we&#8217;re seeing minuscule amounts of CPU usage even at 350 MHz, so it&#8217;s clear that the NEON optimisations are really paying off here.</p>

<p>The astute reader would have noticed that since the device&#8217; native sample rate is 48 kHz, the CPU usage for 48 kHz playback should be less than for 44.1 kHz. This is true with PulseAudio, but not with AudioFlinger! The reason for this little quirk is that AudioFlinger provides 44.1 kHz samples to the HAL (which means the stream is resampled there), and then the HAL needs to resample it again to 48 kHz to bring it to the device&#8217; native rate. From what I can tell, this is a matter of convention with regards to what audio HALs should expect from AudioFlinger (do correct me if I&#8217;m mistaken about the rationale).</p>

<p>So round 1 leans slightly in favour of PulseAudio.</p>

<h2>Round 2: Memory</h2>

<p>Comparing the memory consumption of the server process is a bit meaningless, because the AudioFlinger daemon thread shares an address space with the rest of the <tt>mediaserver</tt> process. For the curious, the resident set size was: AudioFlinger &#8212; 6,796 KB, PulseAudio &#8212; 3,024 KB. Again, this doesn&#8217;t really mean much.</p>

<p>We can, however, compare the client process&#8217; memory consumption. This is <acronym title="Resident Set Size">RSS</acronym> in kilobytes, measured using <tt>top</tt>.</p>

<table>
<colgroup span="2"/>
<colgroup span="2"/>
<tr> <th colspan="2">44.1 kHz</th> <th colspan="2">48 kHz</th> </tr>
<tr> <th>AF</th> <th>PA</th> <th>AF</th> <th>PA</th> </tr>
<tr> <td>2600 kB</td> <td>3020 kB</td> <td>2604 kB</td> <td>3020 kB</td> </tr>
</table>

<p>The memory consumption is comparable between the two, but leans in favour of AudioFlinger.</p>

<h2>Round 3: Power</h2>

<p>I didn&#8217;t have access to a power monitor, so I decided to use a couple of indirect metrics to compare power utilisation. The first of these is <a href="http://www.lesswatts.org/projects/powertop/">PowerTOP</a>, which is actually a Linux desktop tool for monitoring various power metrics. Happily, someone had already <a href="https://gitorious.org/android/powertop">ported PowerTOP to Android</a>. The tool reports, among other things, the number of wakeups-from-idle per second for the processor as a whole, and on a per-process basis. Since there are multiple threads involved, and PowerTOP&#8217;s per-process measurements are somewhat cryptic to add up, I used the global wakeups-from-idle per second. The &#8220;Idle&#8221; value counts the number of wakeups when nothing is happening. The actual value is very likely so high because the device is connected to my laptop in USB debugging mode (lots of wakeups from USB, and the device is prevented from going into a full sleep).</p>

<table>
<colgroup span="1"/>
<colgroup span="2"/>
<colgroup span="2"/>
<tr> <th></th> <th colspan="2">44.1 kHz</th> <th colspan="2">48 kHz</th> </tr>
<tr> <th>Idle</th> <th>AF</th> <th>PA</th> <th>AF</th> <th>PA</th> </tr>
<tr> <td>79.6</td> <td>107.8</td> <td>87.3</td> <td>108.5</td> <td>85.7</td> </tr>
</table>

<p>The second, similar, data point is the number of interrupts per second reported by <tt>vmstat</tt>. These corroborate the numbers above:</p>

<table>
<colgroup span="1"/>
<colgroup span="2"/>
<colgroup span="2"/>
<tr> <th></th> <th colspan="2">44.1 kHz</th> <th colspan="2">48 kHz</th> </tr>
<tr> <th>Idle</th> <th>AF</th> <th>PA</th> <th>AF</th> <th>PA</th> </tr>
<tr> <td>190</td> <td>266</td> <td>215</td> <td>284</td> <td>207</td> </tr>
</table>

<p>PulseAudio&#8217;s power-saving features are clearly highlighted in this comparison. AudioFlinger causes <em>about three times the number of wakeups per second</em> that PulseAudio does. Things might actually be worse on older hardware with less optimised drivers than the Galaxy Nexus (I&#8217;d appreciate reports from running similar tests on a Nexus S or any other device with ALSA support to confirm this).</p>

<p>For those of you who aren&#8217;t familiar with PulseAudio, the reason we manage to get these savings is our timer-based scheduling mode. In this mode, we fill up the hardware buffer as much as possible and go to sleep (disabling ALSA interrupts while we&#8217;re at it, if possibe). We only wake up when the buffer is nearing empty, and fill it up again. More details can be found in this old <a href="http://0pointer.de/blog/projects/pulse-glitch-free.html">blog post by Lennart</a>.</p>

<h2>Round 4: Latency</h2>

<p>I&#8217;ve only had the Galaxy Nexus to actually try this out with, but I&#8217;m pretty certain I&#8217;m not the only person seeing <a href="http://code.google.com/p/android/issues/detail?id=3434">latency issues on Android</a>. On the Galaxy Nexus, for example, the best latency I can get appears to be 176 ms. This is pretty high for certain types of applications, particularly ones that generate tones based on user input.</p>

<p>With PulseAudio, where we dynamically adjust buffering based on what clients request, I was able to drive down the total buffering to approximately 20 ms (too much lower, and we started getting dropouts). There is likely room for improvement here, and it is something on my todo list, but even out-of-the-box, we&#8217;re doing quite well.</p>

<h2>Round 5: Features</h2>

<p>With the hard numbers out of the way, I&#8217;d like to talk a little bit about what else PulseAudio brings to the table. In addition to a playback/record API, AudioFlinger provides mechanism for enforcing various bits of policy such as volumes and setting the &#8220;active&#8221; device amongst others. PulseAudio exposes similar functionality, some as part of the client API and the rest via the core API exposed to modules.</p>

<p>From <acronym title="System-on-Chip">SoC</acronym> vendors&#8217; perspective, it is often necessary to support both Android and standard Linux on the same chip. Being able to focus only on good quality ALSA drivers and knowing that this will ensure quality on both these systems would be a definite advantage in this case.</p>

<p>The current Android system leaves power management to the audio HAL. This means that each vendor needs to implement this themselves. Letting PulseAudio manage the hardware based on requested latencies and policy gives us a single point of control, greatly simplifying the task of power-management and avoiding code duplication.</p>

<p>There are a number of features that PulseAudio provides that can be useful in the various scenarios where Android is used. For example, we support transparently streaming audio over the network, which could be a handy way of supporting playing audio from your phone on your TV completely transparently and out-of-the-box. We also support compressed formats (AC3, DTS, etc.) which the ongoing Android-on-your-TV efforts could likely take advantage of.</p>

<p><em>Edit: As someone pointed out on LWN, I missed one thing &#8212; AudioFlinger has an effect API that we do not yet have in PulseAudio. It&#8217;s something I&#8217;d definitely like to see added to PulseAudio in the future.</em></p>

<h2>Ding! Ding! Ding!</h2>

<p>That pretty much concludes the comparison of these two audio daemons. Since the Android-side code is somewhat under-documented, I&#8217;d welcome comments from readers who are familiar with the code and history of AudioFlinger.</p>

<p>I&#8217;m in the process of pushing all the patches I&#8217;ve had to write to the various upstream projects. A number of these are merely build system patches to integrate with the Android build system, and I&#8217;m hoping projects are open to these. Instructions on building this code will be available on the <a href="http://www.pulseaudio.org/wiki/Android">PulseAudio Android wiki page</a>.</p>

<p>For future work, it would be interesting to write a wrapper on top of PulseAudio that exposes the AudioFlinger audio and policy APIs &#8212; this would basically let us run PulseAudio as a drop-in AudioFlinger replacement. In addition, there are potential performance benefits that can be derived from using Android-specific infrastructure such as Binder (for <acronym title="Inter-Process Communication">IPC</acronym>) and <tt>ashmem</tt> (for transferring audio blocks as shared memory segments, something we support on desktops using the standard Linux SHM mechanism which is not available on Android).</p>

<p>If you&#8217;re an OEM who is interested in this work, you can get in touch with us &#8212; details are on the <a href="http://www.collabora.com/contact/">Collabora website</a>.</p>

<p>I hope this is useful to some of you out there!</p>
]]></content:encoded>
			<wfw:commentRss>http://arunraghavan.net/2012/01/pulseaudio-vs-audioflinger-fight/feed/</wfw:commentRss>
		<slash:comments>47</slash:comments>
		</item>
		<item>
		<title>i&#8217;m in yur analog gain, controlling it</title>
		<link>http://arunraghavan.net/2011/11/im-in-yur-analog-gain-controlling-it/</link>
		<comments>http://arunraghavan.net/2011/11/im-in-yur-analog-gain-controlling-it/#comments</comments>
		<pubDate>Mon, 07 Nov 2011 19:13:00 +0000</pubDate>
		<dc:creator>Arun</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[collabora]]></category>
		<category><![CDATA[f/oss]]></category>
		<category><![CDATA[gnome]]></category>
		<category><![CDATA[pulseaudio]]></category>
		<category><![CDATA[work]]></category>

		<guid isPermaLink="false">http://arunraghavan.net/?p=1169</guid>
		<description><![CDATA[Longish day, but I did want to post something fun before going to sleep &#8212; I just pushed out patches to hook up the WebRTC folks&#8217; analog gain control to PulseAudio. So your mic will automatically adjust the input level based on how loud you&#8217;re speaking. It&#8217;s quite quick to adapt if you&#8217;re too loud, [...]]]></description>
			<content:encoded><![CDATA[<p>Longish day, but I did want to post something fun before going to sleep &#8212; I just pushed out patches to hook up the WebRTC folks&#8217; analog gain control to PulseAudio. So your mic will automatically adjust the input level based on how loud you&#8217;re speaking. It&#8217;s quite quick to adapt if you&#8217;re too loud, but a bit slow when the input signal is too soft. This isn&#8217;t bad, since the former is a much bigger problem than the latter.</p>

<p>Also, we&#8217;ve switched to the WebRTC canceller as the default canceller (you can still choose the Speex canceller manually, though). Overall, the quality is pretty good. I&#8217;d do a demo, but it&#8217;s effectively had zero learning time in my tests, so we&#8217;re not too far from a stage where this is a feature that, <em>if we&#8217;re doing it right you won&#8217;t notice it exists</em>.</p>

<p>There lot&#8217;s of things, big and small that need to be added and tweaked, but this does go some way towards bringing a hassle-free VoIP experience on Linux closer to reality. Once again, kudos to the folks at Google for the great work and for opening up this code. Also a shout-out to fellow <a href="http://www.collabora.com">Collaboran</a> <a href="http://sjoerd.luon.net/blog/">Sjoerd Simons</a> for bouncing ideas and giving me those much-needed respites from talking to myself. :)</p>
]]></content:encoded>
			<wfw:commentRss>http://arunraghavan.net/2011/11/im-in-yur-analog-gain-controlling-it/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Notes from the Prague Audio BoFs</title>
		<link>http://arunraghavan.net/2011/11/notes-from-the-prague-audio-bofs/</link>
		<comments>http://arunraghavan.net/2011/11/notes-from-the-prague-audio-bofs/#comments</comments>
		<pubDate>Thu, 03 Nov 2011 07:06:13 +0000</pubDate>
		<dc:creator>Arun</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[collabora]]></category>
		<category><![CDATA[f/oss]]></category>
		<category><![CDATA[gnome]]></category>
		<category><![CDATA[gstreamer]]></category>
		<category><![CDATA[pulseaudio]]></category>

		<guid isPermaLink="false">http://arunraghavan.net/?p=1123</guid>
		<description><![CDATA[As I&#8217;d blogged about last week, we had a couple of Audio BoF sessions last week. Here&#8217;s a summary of what was discussed. I&#8217;ve collected items in relevance order rather than chronological order to make for easier reading. I think I have everything covered, I&#8217;ll update this post if one of the attendees points out [...]]]></description>
			<content:encoded><![CDATA[<p>As I&#8217;d blogged about last week, we had a couple of Audio <acronym title="Birds of a Feather">BoF</acronym> sessions last week. Here&#8217;s a summary of what was discussed. I&#8217;ve collected items in relevance order rather than chronological order to make for easier reading. I think I have everything covered, I&#8217;ll update this post if one of the attendees points out something I missed or got wrong.</p>

<ul>
<li><p><strong>Surround</strong>: There were a number of topics that came up with regards to multichannel/surround support:</p>

<ul>
<li><p>There seems to be some lack of uniformity of channel maps, particularly in non-HDA hardware. While it was agreed that this should be fixed, we need some directed testing and bug reports to actually be able to fix this.</p></li>
<li><p>Multichannel mixers, while theoretically supported, are not actually exposed by any current drivers. It was suggested that these could be exposed without breaking existing applications by having new MC mixers exposed with device names corresponding to the surround PCM device (like &#8220;surround51&#8243;).</p></li>
<li><p>We need a way to query channel maps on a given PCM. This will be implemented as a new ALSA API which could be called after the PCM is opened. (<em>AI: Takashi</em>)</p></li>
<li><p>It would be good to have a way to configure the channel map as well (if supported by the hardware?). The suggestion was to do this as was done in PulseAudio, where an arbitrary channel map could be specified. (NB: is there hardware that supports multiple/arbitrary channel maps? If yes, how do we handle this?)</p></li>
</ul></li>
<li><p><strong>Routing</strong>: Unsurprisingly, we came back to the problem of building a simplified mixer graph for PulseAudio.</p>

<ul>
<li><p>The current status is that ALSA builds a simplified mixer for use by userspace, and PulseAudio further simplifies this by means of some name-based guessing.</p></li>
<li><p>PulseAudio would ideally like a simplified version of the original mixer graph, but something more complete than what we get now</p></li>
<li><p>However, since PulseAudio has fairly unique requirements of what information it wants, it probably makes sense to have ALSA provide the entire graph and leave the simplification task to PulseAudio (discussion on this approach continues)</p></li>
<li><p>There was no consensus on who would do this or how this should be done (creating a new serialisation format, exposing what HDA provides, adding node metadata to ALSA mixer controls, or something else altogether)</p></li>
<li><p>As an interim step, it was agreed that it would be possible to provide ordering in the simplified ALSA mixer (that is, add metadata to the control to signal what control comes &#8220;before&#8221; it and what comes &#8220;after&#8221; it). This should go some way in making the PA mixer simplification logic simpler and more robust. (<em>AI: Takashi</em>)</p></li>
</ul></li>
<li><p><strong>HDMI</strong>: A couple of things came up in discussion about the status of HDMI.</p>

<ul>
<li><p>There was a question about the reliability of <acronym title="EDID-like data">ELD</acronym> information as this will be used more in future versions of PulseAudio. There did not appear to be conclusive evidence in either direction, so we will probably assume that it is reliable and deal with reliability problems as they arise.</p></li>
<li><p>It was mentioned that it might be desirable to only expose the ALSA device if a receiver is plugged in. This had been mooted earlier as something to do in PulseAudio as an alternative. One thing to consider with this approach is dealing with a device switch on the receiver side. Doing this without a notification to userspace was generally agreed to be a bad idea.</p></li>
</ul></li>
<li><p><strong>Jack detection</strong>: The long-standing debate on exposing jacks as input devices or ALSA controls came to a conclusion, with the resolution being that jacks would be exposed as ALSA controls. This requires a change in the kernel (and potentially alsa-lib?) which should not be too complex. Actual buttons (such as volume/mute control) will continue to be input devices. Once this is done, the pending jack detection patches will be adapted to use the new interface. (<em>AI: Takashi (patches are in a branch already!), David</em>)</p></li>
<li><p><strong>UCM</strong>: Another long-standing issue was the merging of the ALSA UCM patches into PulseAudio. Most of the problems thus far had been due to an incomplete understanding of how ALSA and PA concepts mapped to each other. Some consensus was arrived at in this regard after a lengthy discussion:</p>

<ul>
<li><p>As is the case now, every ALSA PCM maps to a PA sink</p></li>
<li><p>Each UCM verb maps to a PA card profile</p></li>
<li><p>Each combination of UCM devices that can be used concurrently maps to a PA port</p></li>
<li><p>Each UCM modifier is mapped to an intended role on the corresponding sink</p></li>
</ul>

<p>The code should (as is in the patches currently submitted) be part of the PA ALSA module, and there will be changes required to use the UCM-specified mixer list instead of PA&#8217;s guessing mechanism. (<em>AI: ???</em>)</p>

<p>(NB: It was mentioned that PulseAudio needs to support multiple intended roles for a sink/source. This is actually already supported &#8212; the intended roles property is a whitespace-separated list of roles)</p>

<p>(NB2: There was further discussion with the Linaro folks this week about the UCM bits, and there&#8217;s likely going to be an IRC/phone gathering to clarify things further in the near future)</p></li>
<li><p><strong>GStreamer latency settings</strong>: We currently do not actually use PulseAudio&#8217;s power saving features from GStreamer for <a href="http://arunraghavan.net/2011/05/more-pulseaudio-power-goodness/">several reasons</a>. Suggestions to over come this were mooted. While no definite agreement was reached, one suggestion was to add a &#8220;powersave&#8221; profile to pulsesink that chose higher latency/buffer-time values. Players would need to set this if they are not using features that break when these values are raised.</p></li>
<li><p><strong>Corking</strong>: The statelessness of current the corking mechanism was discussed in one session, and between the PulseAudio developers later. The problem is that we need to be able to track cork/uncork reasons more closely. This would give us more metadata that is needed to make policy decisions without breaking streams. Particularly, for example, if PA corks a music stream due to an incoming call, then the user plays, then pauses music, and then the call ends, we must not uncork the music stream. We intend to deal with this with two changes:</p>

<ul>
<li><p>We need to add a per-cause cork/uncork request count</p></li>
<li><p>We need to associate a &#8220;generation&#8221; with cork/uncork requests, so certain conditions (such as user intervention) can bump the generation counter, and uncork requests corresponding to old cork requests will be ignored</p></li>
</ul>

<p>This will make it possible to track the various bits of state we need to do the right thing for cases like the one mentioned before.</p></li>
</ul>

<p>So that&#8217;s that &#8212; lots of things discussed, lots of things to do! Thanks to everyone who came for participating.</p>
]]></content:encoded>
			<wfw:commentRss>http://arunraghavan.net/2011/11/notes-from-the-prague-audio-bofs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PragueAudio</title>
		<link>http://arunraghavan.net/2011/10/pragueaudio/</link>
		<comments>http://arunraghavan.net/2011/10/pragueaudio/#comments</comments>
		<pubDate>Mon, 24 Oct 2011 22:23:31 +0000</pubDate>
		<dc:creator>Arun</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[collabora]]></category>
		<category><![CDATA[f/oss]]></category>
		<category><![CDATA[gnome]]></category>
		<category><![CDATA[gstreamer]]></category>
		<category><![CDATA[pulseaudio]]></category>

		<guid isPermaLink="false">http://arunraghavan.net/?p=1117</guid>
		<description><![CDATA[For those who are in Prague for GstConf, LinuxCon, ELCE, etc. &#8212; don&#8217;t forget we&#8217;ve a couple of interesting audio-related things happening: Today (Tuesday), at 4 pm, I&#8217;ll be talking about recent developments in PulseAudio Tomorrow (Wednesday), at 11am, we&#8217;re continuing the Audio BoF that I had [mentioned earlier] (since we ran out of time [...]]]></description>
			<content:encoded><![CDATA[<p>For those who are in Prague for GstConf, LinuxCon, ELCE, etc. &#8212; don&#8217;t forget we&#8217;ve a couple of interesting audio-related things happening:</p>

<ul>
<li>Today (Tuesday), at 4 pm, I&#8217;ll be talking about <a href="http://gstreamer.freedesktop.org/conference/speakers.html#raghavan">recent developments in PulseAudio</a></li>
<li>Tomorrow (Wednesday), at 11am, we&#8217;re continuing the Audio BoF that I had <a href="http://arunraghavan.net/2011/10/more-conferences-than-you-can-shake-a-stick-at/">mentioned earlier</a> (since we ran out of time on Sunday)</li>
</ul>

<p>If you&#8217;re around and interested, do drop in!</p>
]]></content:encoded>
			<wfw:commentRss>http://arunraghavan.net/2011/10/pragueaudio/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Alternate sample rates</title>
		<link>http://arunraghavan.net/2011/10/alternate-sample-rates/</link>
		<comments>http://arunraghavan.net/2011/10/alternate-sample-rates/#comments</comments>
		<pubDate>Tue, 18 Oct 2011 04:34:35 +0000</pubDate>
		<dc:creator>Arun</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[collabora]]></category>
		<category><![CDATA[f/oss]]></category>
		<category><![CDATA[gentoo]]></category>
		<category><![CDATA[gnome]]></category>
		<category><![CDATA[pulseaudio]]></category>
		<category><![CDATA[work]]></category>

		<guid isPermaLink="false">http://arunraghavan.net/?p=1101</guid>
		<description><![CDATA[I&#8217;ve just pushed a bunch of patches by Pierre-Louis Bossart that can have a pretty decent CPU/power impact. These introduce the concept of an &#8220;alternate sample rate&#8221;. Currently, PulseAudio runs all your devices at a default sample rate, which is set to 44.1 kHz on most systems (this can be configured). All streams running at [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve just pushed a bunch of patches by Pierre-Louis Bossart that can have a pretty decent CPU/power impact. These introduce the concept of an &#8220;alternate sample rate&#8221;.</p>

<p>Currently, PulseAudio runs all your devices at a default sample rate, which is set to 44.1 kHz on most systems (this can be configured). All streams running at different sample rates are resampled to this sample rate. Pierre&#8217;s patches add an alternate sample rate that we try to switch to under certain circumstances if it means that we can save on resampling cost. This would happen if the stream uses exactly the alternate sample rate, or some integral-or-so multiple of it.</p>

<p>The default value for the alternate sample rate is 48 kHz. So if you&#8217;re playing a movie off a DVD where the audio track is typically a 48 kHz stream, and your card supports it, we switch to 48 kHz and avoid resampling altogether. Similarly, while making voice calls, common sample rates are 8, 16, and 32 kHz. These can be resampled to 48 kHz much faster than to 44.1 kHz.</p>

<p>Now for the big caveat &#8212; this won&#8217;t work if there&#8217;s any other stream connected to your sink/source. So if your music player is playing (or even paused) when you get that voip call, we can&#8217;t update the rate. This situation can probably be improved by at least allowing corked streams have their sample rate change (so having some random stream connected but not playing &#8212; I&#8217;m looking at you, Flash! &#8212; won&#8217;t block rate updates altogether). Hopefully we&#8217;ll get this fixed before this feature is released in PulseAudio 2.0.</p>

<p>Thanks to Pierre for all his work on this, and to my company, <a href="http://www.collabora.com/projects/pulseaudio">Collabora</a>, for giving me some time for upstream work!</p>
]]></content:encoded>
			<wfw:commentRss>http://arunraghavan.net/2011/10/alternate-sample-rates/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>More conferences than you can shake a stick at</title>
		<link>http://arunraghavan.net/2011/10/more-conferences-than-you-can-shake-a-stick-at/</link>
		<comments>http://arunraghavan.net/2011/10/more-conferences-than-you-can-shake-a-stick-at/#comments</comments>
		<pubDate>Fri, 14 Oct 2011 04:34:26 +0000</pubDate>
		<dc:creator>Arun</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[collabora]]></category>
		<category><![CDATA[conferences]]></category>
		<category><![CDATA[f/oss]]></category>
		<category><![CDATA[gnome]]></category>
		<category><![CDATA[gstreamer]]></category>
		<category><![CDATA[pulseaudio]]></category>

		<guid isPermaLink="false">http://arunraghavan.net/?p=1085</guid>
		<description><![CDATA[Prague is an interesting place to be at this time of the year &#8212; next week it&#8217;s playing host to the Real Time Linux Workshop. The week after that, we have the Kernel Summit, GStreamer Conference, Embedded Linux Conference Europe and LinuxCon Europe. I&#8217;m going to be at the last 3, and there&#8217;s some great [...]]]></description>
			<content:encoded><![CDATA[<p>Prague is an interesting place to be at this time of the year &#8212; next week it&#8217;s playing host to the Real Time Linux Workshop. The week after that, we have the Kernel Summit, GStreamer Conference, Embedded Linux Conference Europe and LinuxCon Europe. I&#8217;m going to be at the last 3, and there&#8217;s some great audio stuff happening!</p>

<p>On the evening of Oct 23rd, we&#8217;re having an Audio BoF to discuss pending issues that cut across the stack &#8212; ALSA, PulseAudio, GStreamer and any other similar bits that people have complaints about.</p>

<p>Then there&#8217;s <a href="http://gstreamer.freedesktop.org/conference/">GstConf</a>, where there are going to be <a href="http://gstreamer.freedesktop.org/conference/gstreamer-conference-timetable.html">a bunch of awesome talks</a>. Also included is a <a href="http://gstreamer.freedesktop.org/conference/speakers.html#raghavan">talk</a> by yours truly about recent developments in the PulseAudio world.</p>

<p>At some point during that week, possibly Oct 26th morning, plans are afoot to have an ALSA BoF to discuss the state and future of the HDA driver.</p>

<p>There are also rumours of excellent beer that will need to be scrupulously verified. ;)</p>

<p>It&#8217;s going to be a pretty exciting week!</p>
]]></content:encoded>
			<wfw:commentRss>http://arunraghavan.net/2011/10/more-conferences-than-you-can-shake-a-stick-at/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>1.w00t!</title>
		<link>http://arunraghavan.net/2011/09/1-w00t/</link>
		<comments>http://arunraghavan.net/2011/09/1-w00t/#comments</comments>
		<pubDate>Tue, 27 Sep 2011 15:33:28 +0000</pubDate>
		<dc:creator>Arun</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[collabora]]></category>
		<category><![CDATA[f/oss]]></category>
		<category><![CDATA[gentoo]]></category>
		<category><![CDATA[gnome]]></category>
		<category><![CDATA[gstreamer]]></category>
		<category><![CDATA[pulseaudio]]></category>
		<category><![CDATA[work]]></category>

		<guid isPermaLink="false">http://arunraghavan.net/?p=1076</guid>
		<description><![CDATA[As Colin Guthrie reports, PulseAudio 1.0 is now out the door! There&#8217;s a lot of new things in the release, and we should be getting a much more regular release schedule going. Head over to the full release notes for more details. A lot of people have contributed to this release and thanks to them [...]]]></description>
			<content:encoded><![CDATA[<p>As <a href="http://colin.guthr.ie/2011/09/one-point-oh/">Colin Guthrie reports</a>, PulseAudio 1.0 is now out the door! There&#8217;s a lot of new things in the release, and we should be getting a much more regular release schedule going. Head over to the <a href="http://www.freedesktop.org/wiki/Software/PulseAudio/Notes/1.0">full release notes</a> for more details.</p>

<p>A lot of people have contributed to this release and thanks to them all. Special props to Colin all the patch-herding, tireless help, and code ninjutsu!</p>

<p>p.s.: Gentoo packages are already available, of course. :)</p>
]]></content:encoded>
			<wfw:commentRss>http://arunraghavan.net/2011/09/1-w00t/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>LPC ho!</title>
		<link>http://arunraghavan.net/2011/09/lpc-ho/</link>
		<comments>http://arunraghavan.net/2011/09/lpc-ho/#comments</comments>
		<pubDate>Sat, 03 Sep 2011 06:01:35 +0000</pubDate>
		<dc:creator>Arun</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[collabora]]></category>
		<category><![CDATA[gnome]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[pulseaudio]]></category>
		<category><![CDATA[work]]></category>

		<guid isPermaLink="false">http://arunraghavan.net/2011/09/lpc-ho/</guid>
		<description><![CDATA[I&#8217;m going to be at the Linux Plumbers&#8217; Conference next week, speaking about the things we&#8217;ve been doing to make passthrough audio on Linux kick ass. If you&#8217;re around and interested, do drop by!]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m going to be at the <a href="http://www.linuxplumbersconf.org/2011/">Linux Plumbers&#8217; Conference</a> next week, speaking about the things we&#8217;ve been doing to make <a href="http://www.linuxplumbersconf.org/2011/ocw/sessions/117">passthrough audio on Linux</a> kick ass.</p>

<p>If you&#8217;re around and interested, do drop by!</p>
]]></content:encoded>
			<wfw:commentRss>http://arunraghavan.net/2011/09/lpc-ho/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hello &#8230; hello &#8230; hello!</title>
		<link>http://arunraghavan.net/2011/08/hello-hello-hello/</link>
		<comments>http://arunraghavan.net/2011/08/hello-hello-hello/#comments</comments>
		<pubDate>Thu, 25 Aug 2011 08:11:41 +0000</pubDate>
		<dc:creator>Arun</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[collabora]]></category>
		<category><![CDATA[f/oss]]></category>
		<category><![CDATA[gnome]]></category>
		<category><![CDATA[gstreamer]]></category>
		<category><![CDATA[pulseaudio]]></category>
		<category><![CDATA[work]]></category>

		<guid isPermaLink="false">http://arunraghavan.net/?p=1044</guid>
		<description><![CDATA[I have a secret to confess. I&#8217;ve spent a great deal of time over the last few months talking to myself. I can&#8217;t say I haven&#8217;t enjoyed it &#8212; it turns out my capacity to entertain myself is far greater than initially suspected. But I hear you ask &#8230; why? Here at Collabora, I&#8217;ve been [...]]]></description>
			<content:encoded><![CDATA[<p>I have a secret to confess. I&#8217;ve spent a great deal of time over the last few months talking to myself. I can&#8217;t say I haven&#8217;t enjoyed it &#8212; it turns out my capacity to entertain myself is far greater than initially suspected. But I hear you ask &#8230; why?</p>

<p>Here at <a href="http://www.collabora.com/">Collabora</a>, I&#8217;ve been building on <a href="http://blogs.gnome.org/uraeus/2010/10/07/echo-cancellation-on-linux/">Wim&#8217;s previous work</a> on adding echo cancellation to PulseAudio. Thanks go to Intel for supporting us in continuing this work. Before too long, all this work will be trickling down to your favourite Linux distribution and all your friends will stop hating you.</p>

<p>First, a quick recap on <em>what</em> acoustic echo cancellation (AEC) is. If you already know this, you might want to skip this paragraph and the next. Say you&#8217;re on your laptop, and you receive a voice call from your friend. You don&#8217;t have a pair of headphones lying around, so you&#8217;re just going to use your laptop&#8217;s built-in speakers and mic. When your friend speaks, what she says is played out the speakers, but is also captured by the microphone and she gets to hear herself speak, albeit a short while (a few hundred milliseconds or more) later. This is called acoustic echo, and can be frustrating enough to make conversation nigh impossible. There are other types of echo for phone systems, but that&#8217;s not interesting to us at the moment.</p>

<p>This problem is common on pretty much all devices that you use to make phone calls. Astute readers will ask why they don&#8217;t actually face this problem on their phone. That&#8217;s because your phone (or, if you have a cheap phone, your phone company) has special software hidden away that removes the echo before sending your signal along to the other end. On laptops, which are general-purpose hardware, the job of echo cancellation is left to either your operating system (Windows XP onwards, for example) or your chat client (Skype, for example) to provide.</p>

<p>On Linux, we implement echo cancellation as a PulseAudio module (code-ninja Wim Taymans wrote this last year). We use the Speex DSP library to perform the actual echo cancellation.  The code&#8217;s quite modular, so it&#8217;s not very hard to plug in alternate echo cancellers (we even include an <a href="http://www.andreadrian.de/intercom/">alternate implementation</a>, which isn&#8217;t quite as effective as Speex).</p>

<p>Recently, we plugged in some more bits from the Speex library to do noise suppression and digital gain control (so you can quit twiddling with your mic volume for the other end to be able to hear you). We also added a bunch of fixes to reduce CPU consumption significantly &#8212; this should be good enough to run on a netbook and reasonably recent ARM platforms.</p>

<p>While all this sounds nice, I think a demo would sound (haha!) nicer &#8230;</p>

<p>Without AEC: <!-- degradable html5 audio and video plugin --><div class="audio_wrap html5audio"><audio controls id="html5audio-0" class="html5audio"><source src="/downloads/pulseaudio/aec/call-no-aec.m4a" type="audio/mp4" /><source src="/downloads/pulseaudio/aec/call-no-aec.oga" type="audio/ogg" /><a href="http://arunraghavan.net/downloads/pulseaudio/aec/call-no-aec.mp3" title="Click to open" id="f-html5audio-0">Audio MP3</a><script type="text/javascript">AudioPlayer.embed("f-html5audio-0", {soundFile: "/downloads/pulseaudio/aec/call-no-aec.mp3"});</script></audio></div> (or download <a href="http://arunraghavan.net/downloads/pulseaudio/aec/call-no-aec.oga">ogg</a>, <a href="http://arunraghavan.net/downloads/pulseaudio/aec/call-no-aec.m4a">aac</a>)</p>

<p>With AEC: <!-- degradable html5 audio and video plugin --><div class="audio_wrap html5audio"><audio controls id="html5audio-1" class="html5audio"><source src="/downloads/pulseaudio/aec/call-with-aec.m4a" type="audio/mp4" /><source src="/downloads/pulseaudio/aec/call-with-aec.oga" type="audio/ogg" /><a href="http://arunraghavan.net/downloads/pulseaudio/aec/call-with-aec.mp3" title="Click to open" id="f-html5audio-1">Audio MP3</a><script type="text/javascript">AudioPlayer.embed("f-html5audio-1", {soundFile: "/downloads/pulseaudio/aec/call-with-aec.mp3"});</script></audio></div> (or download <a href="http://arunraghavan.net/downloads/pulseaudio/aec/call-with-aec.oga">ogg</a>, <a href="http://arunraghavan.net/downloads/pulseaudio/aec/call-with-aec.m4a">aac</a>)</p>

<p>This is a recording of a call between my laptop and N900. The laptop is playing audio out the speakers and recording with the built-in mic. What you hear is the conversation as heard on the N900.</p>

<p>All this echo cancelling goodness will come to a Linux distribution near you in the upcoming 1.0 release of PulseAudio. The next version of the GNOME IM client, Empathy (3.2), will actually make use of this functionality. In due time, we intend to make it so that all voice applications will end up using this functionality (so if you&#8217;re writing a <acronym title="Voice over IP">VoIP</acronym> application and don&#8217;t want to use this functionality, you need to set a special stream property to disable this &#8212; <tt>filter.suppress="echo-cancel"</tt>).</p>

<p>For the impatient among you, you can try all this out by getting recent testing versions of PulseAudio (I know packages are available for Ubuntu, Debian, Gentoo and Mageia at least). To force your phone streams to use echo cancellation, just run <tt>pactl load-module module-echo-cancel</tt>, and you&#8217;re done.</p>

<p>There&#8217;s still some work to be done, refining quality and using other AEC implementations (in the short-term, the WebRTC one looks promising). Things don&#8217;t work at all if you&#8217;re using different devices for playback and capture (e.g. laptop speakers and webcam mic). These are things that will be addressed in coming weeks and months.</p>
]]></content:encoded>
			<wfw:commentRss>http://arunraghavan.net/2011/08/hello-hello-hello/feed/</wfw:commentRss>
		<slash:comments>19</slash:comments>
		</item>
		<item>
		<title>Desktop Summit 2011</title>
		<link>http://arunraghavan.net/2011/08/desktop-summit-2011/</link>
		<comments>http://arunraghavan.net/2011/08/desktop-summit-2011/#comments</comments>
		<pubDate>Sun, 07 Aug 2011 10:27:45 +0000</pubDate>
		<dc:creator>Arun</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[collabora]]></category>
		<category><![CDATA[f/oss]]></category>
		<category><![CDATA[gentoo]]></category>
		<category><![CDATA[gnome]]></category>
		<category><![CDATA[pulseaudio]]></category>

		<guid isPermaLink="false">http://arunraghavan.net/?p=1038</guid>
		<description><![CDATA[I&#8217;m in Berlin at the Desktop Summit, so you can drop me a note and we can meet if you want to yell about PulseAudio things that annoy you (or even, y&#8217;know, things you like).]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m in Berlin at the Desktop Summit, so you can drop me a note and we can meet if you want to yell about PulseAudio things that annoy you (or even, y&#8217;know, things you like).</p>

<p><a href="http://www.desktopsummit.org/"><img alt="I&#039;m at Desktop Summit 2011" src="/downloads/ds2011banner.png" title="I&#039;m at Desktop Summit 2011" class="aligncenter" width="333" height="110" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://arunraghavan.net/2011/08/desktop-summit-2011/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Updates from the Rygel + DLNA world</title>
		<link>http://arunraghavan.net/2010/08/updates-from-the-rygel-dlna-world/</link>
		<comments>http://arunraghavan.net/2010/08/updates-from-the-rygel-dlna-world/#comments</comments>
		<pubDate>Tue, 17 Aug 2010 14:30:32 +0000</pubDate>
		<dc:creator>Arun</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[collabora]]></category>
		<category><![CDATA[f/oss]]></category>
		<category><![CDATA[gnome]]></category>
		<category><![CDATA[gstreamer]]></category>
		<category><![CDATA[gupnp]]></category>
		<category><![CDATA[rygel]]></category>

		<guid isPermaLink="false">http://arunraghavan.net/?p=926</guid>
		<description><![CDATA[Things have been awfully quiet since Zeeshan&#8217;s posted about the work we&#8217;ve been doing on DLNA support in Rygel. Since I&#8217;ve released GUPnP DLNA 0.3.0, I thought this is a good time to explain what we&#8217;ve been up to. This is also a sort of expansion of my Lightning Talk from GUADEC, since 5 minutes [...]]]></description>
			<content:encoded><![CDATA[<p>Things have been awfully quiet since <a href="http://zee-nix.blogspot.com/">Zeeshan&#8217;s</a> posted about the work we&#8217;ve been doing on <a href="http://lists.o-hand.com/gupnp/0915.html">DLNA support in Rygel</a>. Since I&#8217;ve <a href="http://lists.o-hand.com/gupnp/0984.html">released GUPnP DLNA 0.3.0</a>, I thought this is a good time to explain what we&#8217;ve been up to. This is also a sort of expansion of my Lightning Talk from GUADEC, since 5 minutes weren&#8217;t enough to establish all the background I would have liked to.</p>

<p>For those that don&#8217;t know, the <a href="http://www.dlna.org/"><acronym title="Digital Living Network Alliance">DLNA</acronym></a> is a consortium that aims to standardise how various media devices around your house communicate with each other (that is, your home theater, TV, laptop, phone, tablet, &#8230;). One piece of this problem is having a standard way of identifying the <em>type</em> of a file, and communicating this between devices. For example, say your laptop (MediaServer in DLNA parlance) is sharing the movies you&#8217;ve got with your TV (MediaPlayer), and your TV can play only upto 720p H.264-encoded video. When the MediaServer is sharing files, it needs to provide sufficient information about the file so that the MediaPlayer knows whether it can play it or not, so that it can be intelligent about what files show up in its UI.</p>

<p>How the DLNA specification achieves this is by using &#8220;profiles&#8221;. For each media format supported by the DLNA specification, a number of profiles are defined, that identify the audio/video codec used, the container, and (in a sense) the complexity of decoding the file. (for multimedia geeks, that translates to things like the codec profile, resolution, framerate/samplerate, bitrate, etc.)</p>

<p>For example, if a file is indicated to be of a DLNA profile named <tt>AAC_ISO_320</tt>, this indicates that this is an audio file encoded with the AAC codec, contained in an MP4 container (that&#8217;s &#8220;ISO&#8221;), with a bitrate of at most 320 kbps. Similarly, a file with profile <tt>AVC_MP4_MP_SD_MPEG1_L3</tt> represents a file with H.264 (a.k.a. AVC) video coded in the H.264 Main Profile at specific resolutions upto 720&#215;576, MP3 audio, in an MP4 container (there are more restrictions, but I don&#8217;t want to swamp you with details).</p>

<p>So now we have a problem statement &#8211; given a media file, we need to get the corresponding DLNA profile. It&#8217;s easiest to break this problem into 3 pieces:</p>

<ol>
<li><p><em>Discovery</em>: First we need to get all the metadata that the DLNA specification requires us to check. Using GStreamer and <a href="http://blogs.gnome.org/edwardrv">Edward&#8217;s</a> <a href="http://blogs.gnome.org/edwardrv/2009/11/30/the-result-of-the-past-few-months-of-hacking/"><tt>gst-convenience</tt></a> library, getting the metadata we needed was reasonably simple. Where the metadata wasn&#8217;t available (mostly codec profiles and bitrate), I&#8217;ve tried to expose the required data from the corresponding GStreamer plugin.</p></li>
<li><p><em>DLNA Profiles</em>: I won&#8217;t rant much about the DLNA specification, because that&#8217;s a whole series of blog posts in itself, but the spec is sometimes overly restrictive and doesn&#8217;t support a number of popular formats (Matroska, AVI, DivX, OGG, Theora). With this in mind, we decided that it would be nice to have a generic way to store the constraints specified by the DLNA specification and use them in our library. We chose to store the profile constraints in XML files. This allows non-programmers to tweak the profile data when their devices resort to non-standard methods to work around the limitations of the DLNA spec.</p></li>
<li><p><em>Matching</em>: With 1. and 2. above in place, we just need some glue code to take the metadata from discovery and match it with the profiles loaded from disk. For the GStreamer hackers in the audience, the profile storage format we chose looks suspiciously like serialized GstCaps, so matching allows us to reuse some GStreamer code. Another advantage of this will be revealed soon.</p></li>
</ol>

<p>So there you have it folks, this covers the essence of what GUPnP DLNA does. So what&#8217;s next?</p>

<ol>
<li><p><em>Frankie Says Relax</em>: Since the DLNA spec can often be too strict about what media is supported, we&#8217;ve decided to introduce a soon-to-come &#8220;relaxed mode&#8221; which should make a lot more of your media match some profile.</p></li>
<li><p><em>I Can Haz Trancoding</em>: While considering how to store the DLNA profiles loaded from the XML on disk, we chose to use <tt>GstEncodingProfile</tt>s from the <tt>gst-convenience</tt> library since the restrictions defined by the DLNA spec closely resemble the kind of restrictions you&#8217;d expect to set while encoding a file (codec, bitrate, resolution, etc. again). One nice fallout of this is that (in theory), it should be easy to reuse these to transcode media that doesn&#8217;t match any profile (the <tt>encodebin</tt> plugin from <tt>gst-convenience</tt> makes this a piece of cake). That is, if GStreamer can play your media, Rygel will be able to stream it.</p></li>
</ol>

<p>Apart from this, we&#8217;ll be adding support for more profiles, extending the API as more uses arise, adding more automated tests, and on and on. If you&#8217;re interested in the code, check out (sic) the <a href="http://gitorious.org/gupnp/gupnp-dlna">repository on Gitorious</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://arunraghavan.net/2010/08/updates-from-the-rygel-dlna-world/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>GUADEC 2010 :(</title>
		<link>http://arunraghavan.net/2010/08/guadec-2010/</link>
		<comments>http://arunraghavan.net/2010/08/guadec-2010/#comments</comments>
		<pubDate>Tue, 17 Aug 2010 07:10:05 +0000</pubDate>
		<dc:creator>Arun</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[collabora]]></category>
		<category><![CDATA[f/oss]]></category>
		<category><![CDATA[gnome]]></category>

		<guid isPermaLink="false">http://arunraghavan.net/?p=917</guid>
		<description><![CDATA[Hopefully that title was provocative enough. ;) No, GUADEC seemed to be a smashing success. If only I had been able to attend instead of lying in bed for 2 days, ill and wondering at the general malignancy of a Universe that would do this to me. Nevertheless, I had a great time meeting all [...]]]></description>
			<content:encoded><![CDATA[<p>Hopefully that title was provocative enough. ;) No, GUADEC seemed to be a smashing success. If only I had been able to attend instead of lying in bed for 2 days, ill and wondering at the general malignancy of a Universe that would do this to me.</p>

<div id="attachment_918" class="wp-caption alignright" style="width: 310px"><a href="http://arunraghavan.net/wp-content/uploads/collabora-multimedia-the-hague.jpg"><img src="http://arunraghavan.net/wp-content/uploads/collabora-multimedia-the-hague-300x225.jpg" alt="" title="Collabora Multimedia at The Hague" width="300" height="225" class="size-medium wp-image-918" /></a><p class="wp-caption-text">Collabora Multimedians, looking for a canal</p></div>

<p>Nevertheless, I had a great time meeting all the cool folks at Collabora Multimedia at our company meeting. Managed to trundle out for my Rygel + DLNA lightning talk (more updates on this in a subsequent post). Things did get better subsequently, and I had an amazing week-long vacation in Germany, and now I&#8217;m back at home with my ninja skillz fully recharged!</p>
]]></content:encoded>
			<wfw:commentRss>http://arunraghavan.net/2010/08/guadec-2010/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Pure EFI Linux Boot on Macbooks</title>
		<link>http://arunraghavan.net/2010/02/pure-efi-linux-boot-on-macbooks/</link>
		<comments>http://arunraghavan.net/2010/02/pure-efi-linux-boot-on-macbooks/#comments</comments>
		<pubDate>Sun, 21 Feb 2010 18:01:39 +0000</pubDate>
		<dc:creator>Arun</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[collabora]]></category>
		<category><![CDATA[f/oss]]></category>
		<category><![CDATA[gentoo]]></category>
		<category><![CDATA[laptop]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[macbook]]></category>

		<guid isPermaLink="false">http://arunraghavan.net/?p=903</guid>
		<description><![CDATA[My company was really kind to get me a Macbook Pro (the 13.3-inch &#8220;5.5&#8243; variant). It is an awesome piece of hardware! (especially after my own PoS HP laptop I&#8217;ve been cussing at for a while now) That said, I still don&#8217;t like the idea of running a proprietary operating system on it (as beautiful [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.collabora.co.uk/about/multimedia">My company</a> was really kind to get me a Macbook Pro (the 13.3-inch &#8220;5.5&#8243; variant). It is an <em>awesome</em> piece of hardware! (especially after my own PoS HP laptop I&#8217;ve been cussing at for a while now)</p>

<p>That said, I still don&#8217;t like the idea of running a proprietary operating system on it (as beautiful as OS X is ;)), so I continue to happily use Gentoo. The standard amd64 install works just fine with some minor hiccups (keyboard doesn&#8217;t work on the LiveCD, kernel only shows a console with <tt>vesafb</tt>).</p>

<p>The one thing that did bother me is BIOS-emulation. For those coming from the PC world, Macs don&#8217;t have a BIOS. They run something called <a href="http://en.wikipedia.org/wiki/Extensible_Firmware_Interface"><acronym name="Extensible Firmware Interface">EFI</acronym></a> which is significantly more advanced (though I think the jury&#8217;s out on quirkiness issues and Linus certainly doesn&#8217;t approve of the added complexity).</p>

<p>Anyway, in order to support booting other OSes (=> Windows) exactly as they would on PCs, Apple has added a BIOS emulation layer. This is how Ubuntu (at least as of 9.10) boots on Macbooks. Given that both the bootloader (be it Grub2 or elilo) and the Linux kernel support booting in an EFI environment, it rubbed me the wrong way to take the easy way out and just boot them in BIOS mode. There is a reasonable technical argument for this &#8211; I see no good reason to add one more layer of software (read bugs) when there is no need at all. After a lot of pain, I did manage do make Linux boot in EFI-only mode. There is not enough (accurate, easily-findable) documentation out there, so this is hard-won knowledge. :) I&#8217;m putting this up to help others avoid this pain.</p>

<p>Here&#8217;s what I did (I <em>might</em> be missing some stuff since this was done almost a month ago). The basic boot steps look something like this:</p>

<ol>
<li>EFI firmware starts on boot</li>
<li>Starts <a href="http://refit.sourceforge.net/">rEFIt</a>, a program that extends the default bootloader to provide a nice bootloader menu, shell, etc.</li>
<li>Scans FAT/HFS partitions (no ext* support, despite some claims on the Internet) for bootable partitions (i.e. having a /efi/&#8230; directory with valid boot images)</li>
<li>Runs the Grub2 EFI image from a FAT partition</li>
<li>Loads the Linux kernel (and initrd/initramfs if any) from /boot</li>
<li>Kernel boots normally with whatever your root partition is</li>
</ol>

<p>Now you could use elilo instead of Grub2, but I found this it to not work well (or at all) for me, so I just used a Grub2 (1.97.1, with <a href="http://dev.gentoo.org/~ford_prefect/grub-1.97.1-r1.ebuild">some minor modifications</a>) (just adds an &#8220;efi&#8221; USE-flag to build with <tt>--with-platform=efi</tt>). While I could make /boot a FAT partition, this would break the installkernel script (it&#8217;s run by make install in your kernel source directory), which makes symlinks for your latest/previous kernel image.</p>

<p>Instructions for installing the Grub2 EFI image are <a href="http://grub.enbug.org/TestingOnEFI">here</a>. Just ignore the &#8220;bless&#8221; instructions (that&#8217;s for OS X), and put the EFI image and other stuff in something like <tt>/efi/grub</tt> (the <tt>/efi</tt> is mandatory). You can create a basic config file using <tt>grub-mkconfig</tt> and then tweak it to taste. The Correct Way™ to do this, though, is to edit the files in <tt>/etc/grub.d/</tt>.</p>

<p>Of course, you need to enable EFI support in the kernel, but that&#8217;s it. With this, you&#8217;re all set for the (slightly obsessive-compulsive) satisfaction of not having to enable yet another layer to support yet another proprietary interface, neither of which you have visibility or control over.</p>
]]></content:encoded>
			<wfw:commentRss>http://arunraghavan.net/2010/02/pure-efi-linux-boot-on-macbooks/feed/</wfw:commentRss>
		<slash:comments>25</slash:comments>
		</item>
		<item>
		<title>(Gst)Discovering Vala</title>
		<link>http://arunraghavan.net/2010/01/gstdiscovering-vala/</link>
		<comments>http://arunraghavan.net/2010/01/gstdiscovering-vala/#comments</comments>
		<pubDate>Sat, 16 Jan 2010 10:55:17 +0000</pubDate>
		<dc:creator>Arun</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[collabora]]></category>
		<category><![CDATA[f/oss]]></category>
		<category><![CDATA[gnome]]></category>
		<category><![CDATA[gstreamer]]></category>
		<category><![CDATA[rygel]]></category>
		<category><![CDATA[work]]></category>

		<guid isPermaLink="false">http://arunraghavan.net/?p=883</guid>
		<description><![CDATA[My exploits at Collabora Multimedia currently involve a brief detour into hacking on Rygel, specifically improving the DLNA profile name guessing. We wanted to use Edward&#8216;s work on GstDiscoverer work, and Rygel is written in Vala, so the first thing to do was write Vala bindings for GstDiscoverer. This turned out to be somewhat easier [...]]]></description>
			<content:encoded><![CDATA[<p>My exploits at <a href="http://www.collabora.co.uk/about/multimedia">Collabora Multimedia</a> currently involve a brief detour into hacking on <a href="http://live.gnome.org/Rygel">Rygel</a>, specifically improving the <a href="http://www.dlna.org/">DLNA</a> profile name guessing. We wanted to use <a href="http://blogs.gnome.org/edwardrv">Edward</a>&#8216;s work on <a href="http://blogs.gnome.org/edwardrv/2009/11/30/the-result-of-the-past-few-months-of-hacking/">GstDiscoverer work</a>, and Rygel is written in Vala, so the first thing to do was write Vala bindings for GstDiscoverer. This turned out to be somewhat easier and more difficult than initially thought. :)</p>

<p>There&#8217;s a nice <a href="http://live.gnome.org/Vala/Bindings">tutorial</a> for generating Vala bindings that serves as a good starting point. The process basically involves running a tool called <tt>vapigen</tt>, which examines your headers and libraries, and generates a <a href="http://live.gnome.org/GObjectIntrospection">GIR</a> file from them (it&#8217;s an XML file describing your GObject-based API). It then converts this GIR file into a &#8220;VAPI&#8221; file which describes the API in a format that Vala can understand. Sounds simple, doesn&#8217;t it?</p>

<p>Now if only it were <em>that</em> simple :). The introspected file is not perfect, which means you need to manually annotate some bits to make sure the generated VAPI accurately represents the C API. These annotations are specified in a metadata file. You need to include things like &#8220;the string returned by this function must be freed by the caller&#8221; (that&#8217;s a <tt>transfer_ownership</tt>), or, object type <tt>Foo</tt> is derived from object type <tt>FooDaddy</tt>
(specified using the <tt>base_class</tt> directive). Not all these directives are documented, so you might need to grok around the sources (specifically, <tt>vapigen/valagidlparser.vala</tt>) and ask on IRC (<tt>#vala</tt> on <tt>irc.gnome.org</tt>).</p>

<p>All said and done, the process really is quite straightforward. The work is in [my gst-convenience repository][arun-gst-conv-ks.git] right now (should be merged with the main repository soon). I really must thank all the folks on <tt>#vala</tt> who helped me with all the questions and some of the bugs that I discovered. Saved me a lot of frustration!</p>

<p>I&#8217;ve already got Rygel using these bindings, though that&#8217;s not been integrated yet. More updates in days to come.</p>
]]></content:encoded>
			<wfw:commentRss>http://arunraghavan.net/2010/01/gstdiscovering-vala/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The times they are a-changin&#8217;</title>
		<link>http://arunraghavan.net/2009/11/the-times-they-are-a-changin/</link>
		<comments>http://arunraghavan.net/2009/11/the-times-they-are-a-changin/#comments</comments>
		<pubDate>Sat, 21 Nov 2009 05:46:37 +0000</pubDate>
		<dc:creator>Arun</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[beagle]]></category>
		<category><![CDATA[collabora]]></category>
		<category><![CDATA[f/oss]]></category>
		<category><![CDATA[gentoo]]></category>
		<category><![CDATA[gnome]]></category>
		<category><![CDATA[life]]></category>
		<category><![CDATA[pulseaudio]]></category>
		<category><![CDATA[work]]></category>

		<guid isPermaLink="false">http://arunraghavan.net/?p=867</guid>
		<description><![CDATA[Yesterday was my last day at NVidia. I&#8217;ve worked with the Embedded Software team there for the last 15 months, specifically on the system software for a Linux based stack that you will see some time next year. I&#8217;ve had a great time there, learning new things, and doing everything from tweaking bit-banging I&#178;C implementations [...]]]></description>
			<content:encoded><![CDATA[<p>Yesterday was my last day at NVidia. I&#8217;ve worked with the Embedded Software team there for the last 15 months, specifically on the system software for a Linux based stack that you will see some time next year. I&#8217;ve had a great time there, learning new things, and doing everything from tweaking bit-banging I&sup2;C implementations with a <acronym title="Cathode Ray Oscilloscope">CRO</acronym> to tracking down <em>alleged</em> compiler bugs (I&#8217;m looking at you <tt>-fstrict-aliasing</tt>) by wading through ARM assembly.</p>

<p>As some of you might <a href="http://blogs.gnome.org/uraeus/2009/10/23/welcoming-new-team-members-to-collabora-multimedia/">already know</a>, my next step, which has had me bouncing off the walls for the last month, is to join the great folks at <a href="http://www.collabora.co.uk/about/multimedia/">Collabora Multimedia</a> working on the <a href="http://www.pulseaudio.org/">PulseAudio</a> sound server. I&#8217;ll be working from home here, in Bangalore (in your face, 1.5-hour commute!). It is incredibly exciting for me to be working with a talented bunch of folks and actively contributing to open source software as part of my work!</p>

<p>More updates as they happen. :)</p>
]]></content:encoded>
			<wfw:commentRss>http://arunraghavan.net/2009/11/the-times-they-are-a-changin/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>

