<?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>Colin.Guthr.ie &#187; linux</title>
	<atom:link href="http://colin.guthr.ie/tag/linux/feed/" rel="self" type="application/rss+xml" />
	<link>http://colin.guthr.ie</link>
	<description>Illegitimi non carborundum</description>
	<lastBuildDate>Mon, 26 Jul 2010 08:33:41 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Mix it up</title>
		<link>http://colin.guthr.ie/2010/01/mix-it-up/</link>
		<comments>http://colin.guthr.ie/2010/01/mix-it-up/#comments</comments>
		<pubDate>Wed, 06 Jan 2010 11:11:28 +0000</pubDate>
		<dc:creator>Colin</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[kde]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[mandriva]]></category>
		<category><![CDATA[pulseaudio]]></category>
		<category><![CDATA[sound]]></category>

		<guid isPermaLink="false">http://colin.guthr.ie/?p=199</guid>
		<description><![CDATA[Hot on the heels of my Phonon PulseAudio integration, here is another set of patches for kdemultimedia that adds PulseAudio support to KMix \o/ Quick screenie before a more detailed description: What does this mean? Well it means you will typically get three or four tabs in KMix that represent (in order), "Playback Devices", "Capture [...]]]></description>
			<content:encoded><![CDATA[<p>Hot on the heels of my <a href="http://colin.guthr.ie/2009/10/kde-plus-pulseaudio-does-not-equal-sucks/">Phonon PulseAudio integration</a>, here is another set of patches for kdemultimedia that adds PulseAudio support to KMix \o/</p>
<p>Quick screenie before a more detailed description:</p>
<p><a href="http://colin.guthr.ie/wp-content/uploads/2010/01/kmix-pulse.png"><img class="alignnone size-medium  wp-image-201" title="KMix  showing sliders from PulseAudio" src="http://colin.guthr.ie/wp-content/uploads/2010/01/kmix-pulse-300x221.png" alt="KMix window showing two devices, one Stereo, one 5.1" width="300" height="221" /></a><br />
<span id="more-199"></span></p>
<h1>What does this mean?</h1>
<p>Well it means you will typically get three or four tabs in KMix that represent (in order), "Playback Devices", "Capture Devices", "Playback Stream" and "Capture Streams".</p>
<p>All the physical (and virtual) cards' output "sinks" will appear under "Playback Devices". I'm sure the names are pretty obvious so I wont explain further!</p>
<p>The functionality is close to pavucontrol, but with three important exceptions:</p>
<ol>
<li> There is no equiv of the "Configuration" tab to change "Profile" for a given card.</li>
<li>There is no way to change "Ports" for a given Sink/Source (not all sound hardware supports this and it is intended to make this automatic in some cases - i.e. Headphone Jack Sensing - once it becomes reliable upstream in ALSA, but sometimes it will still be user choice (e.g. Amplified vs. Non-Amplified))</li>
<li>There is no way to move an given application from one output to another.</li>
</ol>
<p>For 1 and 2 I intend to (eventually) provide a KCM to go alongside the Multimedia tab. For 3 you can move "categories" of applications to different devices via the Phonon settings in System Settings -&gt; Multimedia already thanks to my previous patches.</p>
<h1>Where can I get it?</h1>
<p>It's already in Mandriva Cooker or you can grab it from my Git repo here: <a href="http://colin.guthr.ie/git/kdemultimedia/log/?h=pulse">http://colin.guthr.ie/git/kdemultimedia/log/?h=pulse</a></p>
<p>The master branch is upstream svn. The pulse branch is my changes. Do a clone then issue:</p>
<pre> git diff master..pulse &gt;mypatch.patch</pre>
<p>or just build it directly.</p>
<p>Hopefully it'll be committed to trunk soon and if all goes well it can be easily backported to Mandriva 2010 too.</p>
<h1>Caveats</h1>
<p>Every time a new slider appears it is added to the "Shortcuts" system. This is OK for hardware devices, but for every application it can get a bit much.... I'll try and find a way to disable this (see "What's Left" below).</p>
<p>PulseAudio supports a pretty crazy limit on the number of channels a device or stream can have. Kmix only has support for a fairly standard set of elements. In come cases not all channels of a given device/stream may be shown in kmix due to this limitation. Stereo -&gt; 5.1 setups should work fine tho'.</p>
<h1>You Suck, I use PA but I want a Real Man's ALSA mixer!</h1>
<p>Whatever floats your boat baby!</p>
<pre> $  KMIX_PULSEAUDIO_DISABLE=1 kmix</pre>
<p>Knock yourself out!</p>
<h1>What's Left?</h1>
<p>I have two remaining issues that I do not think are show stoppers:</p>
<ol>
<li>Everytime a new device shows up a new Global Shortcut dialog appears. I don't think this is any different to ALSA but as I now have per-app volume control, this dialog is also shown everytime a new application plays sound. It only happens the first time a given application plays a sound, but it could still be considered annoying by some.</li>
<li> If there are no capture streams running at startup the tab for that will never be displayed - likewise if the stream restore module in PA is not loaded (unlikely) the "Playback Streams" tab will never be displayed.</li>
<li>There are various things that could be more efficient (e.g. refreshing the GUI for a new device or application current redraws all tabs, not just the one that has changed when a new application appears or disappears)</li>
<li> Make KMix dumber! KMix is pretty clever and it tries to do some smart things like saving and restoring volume for you. But when PA is used, it knows better, so I need to ensure that KMix does not do any saving/restoring of actual volume values.</li>
<li>Use application icons for per-application streams. Just for eye candy, it would be nice to use the applications own icon in the GUI.</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://colin.guthr.ie/2010/01/mix-it-up/feed/</wfw:commentRss>
		<slash:comments>30</slash:comments>
		</item>
		<item>
		<title>PulseAudio Phonon Support now in KDE trunk and heading towards 4.4</title>
		<link>http://colin.guthr.ie/2009/11/pulseaudio-phonon-support-now-in-kde-trunk-and-heading-towards-4-4/</link>
		<comments>http://colin.guthr.ie/2009/11/pulseaudio-phonon-support-now-in-kde-trunk-and-heading-towards-4-4/#comments</comments>
		<pubDate>Fri, 20 Nov 2009 09:48:40 +0000</pubDate>
		<dc:creator>Colin</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[kde]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[pulseaudio]]></category>

		<guid isPermaLink="false">http://colin.guthr.ie/?p=192</guid>
		<description><![CDATA[I've very pleased to announce that my work on Phonon to integrate support for PulseAudio has now been committed to trunk and will form part of KDE 4.4 \o/ There were a few teething problems due to some last minute merges I did (which I clearly didn't test properly - my bad) and which I [...]]]></description>
			<content:encoded><![CDATA[<p>I've very pleased to announce that my work on Phonon to integrate support for PulseAudio has now been committed to trunk and will form part of KDE 4.4 \o/</p>
<p>There were a few teething problems due to some last minute merges I did (which I clearly didn't test properly - my bad) and which I then went on to mis-interpret which led me to commit two rather silly things in phonon (a revert and then a revert of that revert!). What can I say... I need more caffeine obviously!<span id="more-192"></span></p>
<p><strong>Update</strong>: <a href="http://thread.gmane.org/gmane.comp.audio.pulseaudio.general/5265">PulseAudio 0.9.21</a> is now out and has all the necessary fixes to make the below patches unnecessary.</p>
<p>The slightly annoying news is that the support needed for this to work is not yet in a released version of PA. I do however have a simple patch for you <a href="http://svn.mandriva.com/cgi-bin/viewvc.cgi/packages/cooker/pulseaudio/current/SOURCES/0200-Module-Device-Manager-in-development.patch?revision=466708&amp;view=markup">here</a>, that distro packagers are welcome to <span style="text-decoration: line-through;">steal</span>liberate from the Mandriva SVN. If you do this, you'll also need to apply this minor patch to phonon:</p>
<pre>diff --git a/phonon/CMakeLists.txt b/phonon/CMakeLists.txt
index c5ce57a..50a3851 100644
--- a/phonon/CMakeLists.txt
+++ b/phonon/CMakeLists.txt
@@ -8,7 +8,6 @@ endif (PHONON_BUILD_EXAMPLES)

 add_subdirectory(experimental)

-set(PULSEAUDIO_MINIMUM_VERSION "0.9.21")
 macro_optional_find_package(PulseAudio)
 macro_log_feature(PULSEAUDIO_FOUND "PulseAudio" "A cross-platform, networked sound server." "http://www.pulseaudio.org" FALSE "" "Allows audio playback via the PulseAudio soundserver when it is running")
 macro_optional_find_package(GLIB2)</pre>
<p>Just so that it recognises your PA build.</p>
<p>There don't seem to be any specific bugs yet, although I am dealing with something relating to streams going AWOL with Xine, but I'm not sure the problem is in this code. Further testing and feedback is much appreciated. Feel free to report problems to me directly or assign bugs to my kde (at) &lt;this domain&gt; account in b.k.o.</p>
<p>Have fun!</p>
]]></content:encoded>
			<wfw:commentRss>http://colin.guthr.ie/2009/11/pulseaudio-phonon-support-now-in-kde-trunk-and-heading-towards-4-4/feed/</wfw:commentRss>
		<slash:comments>36</slash:comments>
		</item>
		<item>
		<title>So how does the KDE PulseAudio support work anyway?</title>
		<link>http://colin.guthr.ie/2009/10/so-how-does-the-kde-pulseaudio-support-work-anyway/</link>
		<comments>http://colin.guthr.ie/2009/10/so-how-does-the-kde-pulseaudio-support-work-anyway/#comments</comments>
		<pubDate>Thu, 29 Oct 2009 14:42:22 +0000</pubDate>
		<dc:creator>Colin</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[kde]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[pulseaudio]]></category>
		<category><![CDATA[sound]]></category>

		<guid isPermaLink="false">http://colin.guthr.ie/2009/10/so-how-does-the-kde-pulseaudio-support-work-anyway/</guid>
		<description><![CDATA[So I think it's probably worth me writing up just exactly how the PulseAudio support in KDE's Phonon library actually works and why using it will give you some nice extra features! This article follows on from my previous articles here and here. If you've not read them, then it would make sense to give [...]]]></description>
			<content:encoded><![CDATA[<p>So I think it's probably worth me writing up just exactly how the PulseAudio support in KDE's Phonon library actually works and why using it will give you some nice extra features!<span id="more-174"></span></p>
<p>This article follows on from my previous articles <a href="http://colin.guthr.ie/2009/10/kde-plus-pulseaudio-does-not-equal-sucks/">here</a> and <a href="http://colin.guthr.ie/2009/10/update-on-kdepulseaudio/">here</a>. If you've not read them, then it would make sense to give them a quick glance <img src='http://colin.guthr.ie/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  (also as this was composed on my phone while on a flight, please forgive me any silly spelling errors I didn't spot when reviewing it!!)</p>
<p>First of all it's probably worth explaining what happens and what the phonon backend itself needs to be aware of and how it can interoperate with pulse.</p>
<p>So when libphonon is used in an application, a connection to PulseAudio will be attempted. If that connection fails everything will work as currently and nothing much changes. If the connection succeeds, we establish if "module-device-manager" is loaded. This is a module specifically written to implement the routing policy (an ordered priority list of devices for each category of sound produced - e.g. Notifications, Music or Video). If this module is not detected we offer a reduced/cut-down PulseAudio integration where the user will only see a single, virtual "PulseAudio" sound "device" listed in the KDE configuration system's multimedia section. If m-d-m is detected however, users will get the full rich experience. All of the devices ever seen by PulseAudio (I.e. Built in sound cards, PCI devices, USB speakers and headsets, Bluetooth devices and Apple Airtunes devices etc.) will be listed. If the device is not currently available, it will be shown greyed out as expected and you can of course  reorder them to suit your own preferences.</p>
<p>So all that is well and good from a user perspective but "how does it work internally?" I hear you scream!</p>
<h2>The Nitty Gritty</h2>
<p>When m-d-m is used the device preference order is not actually stored in phonon itself as is the case when PulseAudio is not used, it is instead passed across to PulseAudio which takes over responsibility for keeping this priority list up to date. Why do it this way? Well while the preferences stored in KDE work fine for phonon apps they do not cover any non-phonon ones (which still make up the vast majority of sound producing applications on Linux). As someone involved with sound on Linux I've often been asked by confused users why their preferences are not honoured in e.g. Audacious or other non-phonon apps. As PulseAudio is integrated lower down the sound stack than phonon, ensuring it knows your device order preferences also ensures that it can route your audio appropriately according to your preferences for all apps! A clear bonus <img src='http://colin.guthr.ie/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Now as you may know phonon has it's own API calls to move streams to specific devices. This is something also handled in PulseAudio so it makes sense to simply wrap up the phonon API around these PA call which is exactly what I do! However, there is a complication. As phonon has pluggable backends, we don't actually speak to pulse directly to do the sound output (our connection to the PulseAudio daemon is only for querying and control purposes) so we don't know which stream is ours when the audio is actually playing. To get around this obscurity introduced by the pluggable backends, we take advantage of a facility in PulseAudio to attach arbitrary metadata to our streams by way of setting special environment variables. When phonon is instructed to start outputting audio, we set both the PulseAudio "media.role" property (this is the equivalent of the Phonon Categories system and we happily have an easy 1:1 mapping) and we generate a GUID for our stream and assign it as the "phonon.streamid" property. Our control connection sees all audio streams played in PulseAudio and can use this streamid to map back the PulseAudio streams to the phonon streams. This then allows us to process the stream move requests! It's a bit of a round about road to get this capability but it is the only way we can skirt around the obscurity provided by a pluggable backend system in a general way (the opaque interfaces provided by e.g. Xine, GStreamer and other backends would not expose this info directly anyway).</p>
<p>"But wait!" I hear those of you paying close attention scream. "Didn't you say above that PulseAudio will do the routing for us according to our preferences? Why not let it do that for phonon streams as well as non-phonon streams and forget about the whole GUID thing?" Well, if truth be told, I did start off doing it this way but it had two major issues. The first was the "Test" button not working properly - it always resulted in the highest priority device being used, no the one the user had selected! Not really ideal and more than a little confusing I'm sure you'll agree! The second problem related to visual feedback. When you reorder your devices or plug in a device of higher priority when sound is currently playing, phonon will visually inform the user of the device change. Handing over wholesale to PulseAudio meant that this feedback was lost. Again this is certainly not what I'd call seamless integration!</p>
<p>So at present the stream will be routed to the correct device by PulseAudio and then Phonon will also issue a move command which should in most cases be a NOOP. Likewise when devices are hotplugged (or unplugged!) PulseAudio will route them correctly and phonon will follow this up with a specific move request which will again end up being a NOOP.  While this may seem pointless it does allow for the phonon API to be use properly (as needed by the test button) and give visual feedback)</p>
<h2>Backends</h2>
<p>So what does it mean for a backend? Well the backend needs to be somewhat aware of PulseAudio. Thankfully this is pretty trivial thanks to the PulseSupport class I've written. The backend should ask PulseSupport if pulse is detected if so it should check for and enable it's own PulseAudio output system. If this cannot be fond or activated it can tell PulseSupport that it's a no go and everything should fall back to how things work without any PulseAudio support. There are a couple other bits and bobs that a backend needs to do to work fully but that's the bulk of it.</p>
<p>So I hope I've provided a good and in-depth overview of how this support works. Please keep any comments on topic. If you want to post comments about PA in general, please do so on (and after reading!) <a href="http://colin.guthr.ie/2009/08/sound-on-linux-anti-fud-calm-certainty-and-confidence/">this article</a>.</p>
<p>This support is included in the upcoming <a href="http://www.mandriva.com/">Mandriva 2010.0 Release</a> which will be hitting the streets very soon.</p>
]]></content:encoded>
			<wfw:commentRss>http://colin.guthr.ie/2009/10/so-how-does-the-kde-pulseaudio-support-work-anyway/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>Finding (and purging) orphaned packages</title>
		<link>http://colin.guthr.ie/2009/10/finding-and-purging-orphaned-packages/</link>
		<comments>http://colin.guthr.ie/2009/10/finding-and-purging-orphaned-packages/#comments</comments>
		<pubDate>Sun, 11 Oct 2009 11:53:45 +0000</pubDate>
		<dc:creator>Colin</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[mandriva]]></category>

		<guid isPermaLink="false">http://colin.guthr.ie/?p=158</guid>
		<description><![CDATA[For a couple of releases Mandriva's package management tool, urpmi, has come with a feature that tracks and reports on orphaned packages. It does this by tracking which packages were installed as dependencies of others and then reporting back when the package that contained the dependency is no longer present (or it's dep has changed). [...]]]></description>
			<content:encoded><![CDATA[<p>For a couple of releases Mandriva's package management tool, urpmi, has come with a feature that tracks and reports on orphaned packages. It does this by tracking which packages were installed as dependencies of others and then reporting back when the package that contained the dependency is no longer present (or it's dep has changed). This works pretty well, but sometimes you want something that is not based on a tracked state, and just looks at the packages available and those that are installed.<span id="more-158"></span></p>
<p>If you have kept the same install for several distro releases, with just upgrades rather than fresh installs, then chances are you will have quite a few old libraries installed on your system. The easiest way to purge all these no longer needed libraries is to compare the packages that are available via urpmi and what packages are installed. If you have packages that are installed but that are not available to install, chances are it's an orphan.</p>
<p>So I wrote a very simple script that compares the two outputs and I include it here so you can do your own spring cleaning! This is very similar to the yum orphan finding tool on Fedora (well I last tried it a while back, so it may have moved on since then!).</p>
<p>Hope it's useful to some people:</p>
<pre>#!/bin/bash

TMP_AVAILABLE=$(mktemp /tmp/orphans.XXXXXX)
TMP_INSTALLED=$(mktemp /tmp/orphans.XXXXXX)
urpmq -fa . | sort -u &gt;$TMP_AVAILABLE
rpm -qa --nosignature --nodigest --qf '%{name}-%{version}-%{release}.%{arch}\n' | sort -u &gt;$TMP_INSTALLED

diff -u $TMP_AVAILABLE $TMP_INSTALLED | grep "^+[^+]" | cut -b2-

rm -f $TMP_AVAILABLE $TMP_INSTALLED</pre>
]]></content:encoded>
			<wfw:commentRss>http://colin.guthr.ie/2009/10/finding-and-purging-orphaned-packages/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Mandriva 2009.1 and Intel Graphics</title>
		<link>http://colin.guthr.ie/2009/10/mandriva-2009-1-and-intel-graphics/</link>
		<comments>http://colin.guthr.ie/2009/10/mandriva-2009-1-and-intel-graphics/#comments</comments>
		<pubDate>Sun, 11 Oct 2009 11:35:30 +0000</pubDate>
		<dc:creator>Colin</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[intel]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[mandriva]]></category>

		<guid isPermaLink="false">http://colin.guthr.ie/?p=156</guid>
		<description><![CDATA[As many of you already (painfully) know, Mandriva 2009.1 was shipped at a rather awkward time in the Intel Graphics Driver's lifecycle. The upstream guys were in the middle of a rather extensive rewrite and consolidation. This meant that the version shipped with 2009.1 did not work all that well for several users. The new [...]]]></description>
			<content:encoded><![CDATA[<p>As many of you already (painfully) know, Mandriva 2009.1 was shipped at a rather awkward time in the Intel Graphics Driver's lifecycle. The upstream guys were in the middle of a rather extensive rewrite and consolidation. This meant that the version shipped with 2009.1 did not work all that well for several users. The new intel driver requires careful coordination of kernel, libdrm, mesa and intel driver packages to ensure they all work properly. This requirement meant that providing official updates was difficult due to the fact that kernel updates were often required.</p>
<p>For this reason, myself and Thomas Backlund have been operating a semi-official repository of packages built for 2009.1 specifically for Intel users of 2009.1. <span id="more-156"></span>This repository contains the latest version of:</p>
<ul>
<li>Kernel (currently 2.6.31.3)</li>
<li>LibDRM (currently 2.4.14)</li>
<li>Mesa (currently 7.6)</li>
<li>Intel Driver (currently 2.9.0)</li>
</ul>
<p>With these packages installed, performance with the intel driver should be pretty good for most people.</p>
<p>Of course, Mandriva 2010.0 will contain all these versions officially and should present a better OOTB experience for everyone.</p>
<p>The i586 repository can be added via:</p>
<pre>urpmi.addmedia TMB-Intel-32 http://tmb.mine.nu/Mandriva/Intel-2009.1/i586/</pre>
<p>and the x86_64 version:</p>
<pre>urpmi.addmedia TMB-Intel-64 http://tmb.mine.nu/Mandriva/Intel-2009.1/x86_64/</pre>
<p>More information can be found on the Mandriva Bugzilla <a href="https://qa.mandriva.com/show_bug.cgi?id=52601">Bug #52601</a></p>
]]></content:encoded>
			<wfw:commentRss>http://colin.guthr.ie/2009/10/mandriva-2009-1-and-intel-graphics/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Update on KDE+PulseAudio</title>
		<link>http://colin.guthr.ie/2009/10/update-on-kdepulseaudio/</link>
		<comments>http://colin.guthr.ie/2009/10/update-on-kdepulseaudio/#comments</comments>
		<pubDate>Sat, 10 Oct 2009 14:42:21 +0000</pubDate>
		<dc:creator>Colin</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[kde]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[pulseaudio]]></category>

		<guid isPermaLink="false">http://colin.guthr.ie/?p=152</guid>
		<description><![CDATA[Just a small note to update on the progress. The Test button now selects the right device. The way of achieving this is a little convoluted, but it seems to work well. We now generate a UUID for every phonon stream and push this into the PulseAudio stream proplist via an environment variable. We then [...]]]></description>
			<content:encoded><![CDATA[<p>Just a small note to update on the progress.</p>
<p>The Test button now selects the right device. The way of achieving this is a little convoluted, but it seems to work well. We now generate a UUID for every phonon stream and push this into the PulseAudio stream proplist via an environment variable. We then look for all the streams in pulse and match up our UUID such that we can match up the pulse stream index to our phonon stream. We can then use this to move the stream to the appropriate device. Due to the async nature of PulseAudio, phonon sometimes requests the move before the stream is actually setup, so we have to queue up the move requests and process them when a stream appears. This approach also has the effect of causing the specific sink to be saved in module-stream-restore database, but this shouldn't matter in practice as phonon will always move it, so if the priority list changes, then we will always set the right device one way or the other even if the whole rigmarole could be avoided. But like I say, the practical outcome is fine, so let's just leave that for now.</p>
<p>The category is also passed through to PulseAudio now, so the the only thing that is not handled is when PulseAudio disconnects/restarts. Thankfully this is now getting less and less often as stability improves <img src='http://colin.guthr.ie/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://colin.guthr.ie/2009/10/update-on-kdepulseaudio/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>KDE + PulseAudio != Sucks</title>
		<link>http://colin.guthr.ie/2009/10/kde-plus-pulseaudio-does-not-equal-sucks/</link>
		<comments>http://colin.guthr.ie/2009/10/kde-plus-pulseaudio-does-not-equal-sucks/#comments</comments>
		<pubDate>Thu, 01 Oct 2009 23:38:05 +0000</pubDate>
		<dc:creator>Colin</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[kde]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[pulseaudio]]></category>

		<guid isPermaLink="false">http://colin.guthr.ie/?p=147</guid>
		<description><![CDATA[So I've been spending altogether far too much time on getting this stuff working, but it's finally in a state where it no longer sucks. For several releases we (Mandriva) have been patching KDE's phonon support to hide all the real devices if PulseAudio is used because the GUI really makes no sense (PulseAudio handles [...]]]></description>
			<content:encoded><![CDATA[<p>So I've been spending altogether far too much time on getting this stuff working, but it's finally in a state where it no longer sucks.</p>
<p>For several releases we (Mandriva) have been patching KDE's phonon support to hide all the real devices if PulseAudio is used because the GUI really makes no sense (PulseAudio handles all the routing for us). This is an acceptable solution but it's far from ideal.</p>
<p>So with the latest set of three patches (one for pulseaudio, one for phonon and the final one for kdebase4-runtime) I now have a fully working system (albeit with some caveats!).<span id="more-147"></span></p>
<p>So how does it all work? Well The first step is module-device-manager. This is a pulseaudio module that does the following:</p>
<ul>
<li>Store all devices we've ever seen and keep track of their description and their icon.</li>
<li>Provide a protocol extension to allow clients to query this database.</li>
<li>Implement a per-role priority list for devices (again exposing it via the protocol)</li>
<li>Implement a routing policy that will always uses the highest available device for streams with the relevant role.</li>
</ul>
<p>With that in mind, I then patched Phonon to support querying this database and editing the priority list. Normally (e.g. when pulse is not in use) phonon will keep all it's configuration in a simple config file, so I've overridden this when pulse is detected (which now happens via trying to connect to the server, rather than relying on Mandriva specific configs) to instead use our little database.</p>
<p>The final step is a patch to kdebase4-runtime. There was some copied code kicking around which caused a lot of issues with this patch. In the end I had to export a new config class from phonon in order to make this all work (I don't want the KCM tweaking the config file as it will not be used if pulseaudio is in use... so by exporting the config class everying is kept abstracted).</p>
<p>All in all, this means that:</p>
<ul>
<li>All the sinks/sources from PulseAudio are shown in the System Settings -&gt; Multimedia dialog</li>
<li>You can order the devices and this will be honoured and saved to pulseaudio. Audio will be routed according to this preference.</li>
<li>Devices that are unavailable will be shown greyed out.</li>
<li>When devices appear/disappear, they will be automatically used if they are higher up the priority list than what's currently being used.</li>
</ul>
<p>But with all good news there is some bad news! So what's <strong>not</strong> working?</p>
<ul>
<li>Categories are not currently mapped to roles, so the only category list that works is the "default" one (although some applications may have their role guessed by PulseAudio because it parses the data in an applications .desktop file.</li>
<li>Testing a device will not test the specific device you've selected. PulseAudio handles all the routing, so there is no way to force a given device to be used. I'm not sure how to handle this ultimately.</li>
<li>Doesn't handle a PulseAudio restart (aka a crash and respawn!)</li>
</ul>
<p>The phonon patch is being reviewed for upstream inclusion but the API exposed is liable to change, so these patches are not final. Likewise module-device-manager is not yet final and may yet undergo some API changes. But that aside, this is IMO great progress even if I do say so myself!</p>
<p>And what is a blog post without a screenshot eh? OK here you go:</p>
<p><a href="http://colin.guthr.ie/wp-content/uploads/2009/10/phonon-pulse-kde.jpg"><img class="alignnone size-medium wp-image-148" title="KDE GUI" src="http://colin.guthr.ie/wp-content/uploads/2009/10/phonon-pulse-kde-300x177.jpg" alt="KDE GUI" width="300" height="177" /></a></p>
<p>All my git repositories can be found <a href="http://colin.guthr.ie/git/">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://colin.guthr.ie/2009/10/kde-plus-pulseaudio-does-not-equal-sucks/feed/</wfw:commentRss>
		<slash:comments>25</slash:comments>
		</item>
		<item>
		<title>Skype + Pulse Goodness</title>
		<link>http://colin.guthr.ie/2009/08/skype-pulse-goodness/</link>
		<comments>http://colin.guthr.ie/2009/08/skype-pulse-goodness/#comments</comments>
		<pubDate>Thu, 27 Aug 2009 21:14:06 +0000</pubDate>
		<dc:creator>Colin</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[pulseaudio]]></category>
		<category><![CDATA[sound]]></category>

		<guid isPermaLink="false">http://colin.guthr.ie/?p=145</guid>
		<description><![CDATA[Looks like Auld Nick has got some ice skates..... There is a new version of Skype for GNU/Linux! And it supports PulseAudio pretty well First of all I'm quite disappointed by the fact that there is no official Mandriva RPM but as this is a binary only app anyway, it's pretty easy to convert whatever [...]]]></description>
			<content:encoded><![CDATA[<p>Looks like Auld Nick has got some ice skates..... There is a new version of Skype for GNU/Linux! And it supports PulseAudio pretty well <img src='http://colin.guthr.ie/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> <span id="more-145"></span>First of all I'm quite disappointed by the fact that there is no official Mandriva RPM but as this is a binary only app anyway, it's pretty easy to convert whatever else is there to suit your needs.</p>
<p>I only saw one 64 bit package so I figured I'd convert it. It's for Ubuntu, but alien -r skype.deb soon converts that to an RPM. Sadly it turns out that this is not a 64 bit app at all, it's just 32 bit but presumably it's got the necessary dependancies cooked into the package. So overall, the Fedora package will probably run fine on Mandriva.</p>
<p>Once it was installed I fired it up and under sound preferences it just says "PulseAudio" all the way <img src='http://colin.guthr.ie/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  Happy Days.</p>
<p>I found that Skype seemed to try and change volumes a bit and that seemed to trigger an assert in pulse so I disabled the relevant setting in Skype for now and things seem a bit more stable since then.</p>
<p>Now, PulseAudio has some nice features, like corking (pausing if the app supports it) music playback when a call comes in. In order to do this, PulseAudio has to know that Skype is a telephony application. In theory this is just a matter of adding "Telephony" to the Categories in the skype.desktop file. Sadly this didn't seem to work for me... not sure why, but I didn't debug for too long. Instead I added a</p>
<pre>X-PulseAudio-Properties=media.role=phone</pre>
<p>That did the trick. Pulse now knows that Skype is a VoIP app <img src='http://colin.guthr.ie/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>One other neat feature (in addition to the music pausing) is that when I connected my Bluetooth headset half way through a call, PulseAudio moved my call across to the headset automatically! Nice.</p>
<p>So the conclusion? Well, there does still seem to be a few issues with the volume setting but overall, this is a great step forward!</p>
<p>So what next? Well work out why the asserts happen on volume changes and then work out why the Telephony category is not parsed from skype.desktop.</p>
]]></content:encoded>
			<wfw:commentRss>http://colin.guthr.ie/2009/08/skype-pulse-goodness/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Sound on Linux Anti-FUD: Calm, Certainty and Confidence</title>
		<link>http://colin.guthr.ie/2009/08/sound-on-linux-anti-fud-calm-certainty-and-confidence/</link>
		<comments>http://colin.guthr.ie/2009/08/sound-on-linux-anti-fud-calm-certainty-and-confidence/#comments</comments>
		<pubDate>Sun, 02 Aug 2009 15:41:43 +0000</pubDate>
		<dc:creator>Colin</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[pulseaudio]]></category>
		<category><![CDATA[sound]]></category>

		<guid isPermaLink="false">http://colin.guthr.ie/?p=126</guid>
		<description><![CDATA[Over the years I've listened to several opinions expressing doubt over the Linux sound stack. There are lots of ill informed comments out there concerning various things sound related, both positive and negative, but more often than not commentators miss out very important aspects of a modern, multi-user, desktop sound stack. So in this article [...]]]></description>
			<content:encoded><![CDATA[<p>Over the years I've listened to several opinions expressing doubt over the Linux sound stack. There are lots of ill informed comments out there concerning various things sound related, both positive and negative, but more often than not commentators miss out very important aspects of a modern, multi-user, desktop sound stack. So in this article I'll attempt to discuss some of the misconceptions out there, provide a balanced view of the current state of affairs, discuss some of the perceived mistakes in the rollout of new sound stacks and where things are going in the future.<span id="more-126"></span>There have been a <a href="http://insanecoding.blogspot.com/2007/05/sorry-state-of-sound-in-linux.html">few</a> <a href="http://insanecoding.blogspot.com/2009/06/state-of-sound-in-linux-not-so-sorry.html">articles</a>, some picking up <a href="http://linux.slashdot.org/story/09/06/19/1937210/State-of-Sound-Development-On-Linux-Not-So-Sorry-After-All">mainstream</a> coverage talking about the Linux sound stack. Some comments suggest that it's not that bad, but totally miss the point regarding what a desktop audio stack is all about, but most people are talking about how it's in a bad way and overly complicated and while such comments do have some merit, things really are not that bad, and I believe there is a really bright future.</p>
<h2>ALSA vs OSS</h2>
<p>A lot of the comments of late have been discussing things such as how amazingly brilliant OSS is. Personally I don't buy it. I've never really played overly much with OSS and as such this is probably a slightly ill-informed view - although that's not to say it's not accurate of course <img src='http://colin.guthr.ie/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> . Most of these kind of comments are made by people who don't really understand ALSA and are bought over by the "ALSA API is overly complex" type comments. Yes, the ALSA client library is rather complex and has numerous pitfalls - so much so that there exists now an unofficial <a href="http://0pointer.de/blog/projects/guide-to-sound-apis.html">"safe" ALSA Subset</a> API. But what people invariably fail to comment on (and thus fully understand) is that ALSA comes in two parts: the kernel driver and the userspace library. ALSA differs from OSS in that all access to the kernel layer is performed via a userspace library. I don't know of any ALSA clients that communicate directly with the kernel layer without going through libasound. What this means is that the kernel interface has the freedom to be re-factored and improved at any time, provided the userspace library is developed in parallel. For this reason, the kernel layer is actually quite clean and well defined. The rather rigorous quality control that goes on in the kernel is testament to the fact that on the kernel side of things, ALSA is doing pretty well. Of course there can (and will be) improvements in this area in the future, but this side of things is certainly not in a poor state as people seem to assume.</p>
<p>The "too complex" argument relates to the ALSA <strong>userspace</strong> API. In order to remain backwards compatible, the userspace API has undergone several refinements. As will anything not designed from the top down, some parts of it are rather confusing and have sometimes been misinterpreted (the classic example here being the confusion over snd_pcm_delay() - it's documentation hinting at a hardware based implementation that subsequently lead to some project (i.e. <a href="http://www.winehq.org/">WINE</a>) assuming that this function will eventually return 0 which is not true; fortunately this problem is behind us now, but with a new API call added that does return the info the WINE guys (and others) needed).</p>
<p>So yes, the ALSA userspace API could use a complete top-down redesign, but in order to do that, we would immediately break compatibility with 90% of the apps out there: Not a great idea all in all. Retaining backwards compatibility is a pain, but it's also quite important!</p>
<h2>But Sound Servers Suck!</h2>
<p>What is in a name? That which we call a rose by any other name would smell as sweet. Some people seem to have some sort of built in hatred of "sound servers" as a concept without really thinking through what this means. Yes, there have been some pretty awful experiences with some sound servers in the past (EsounD and aRTs being the immediate examples that spring to mind), but that doesn't mean the concept itself is flawed. You may drive a couple of shit cars but doesn't mean we should all abandon the roads. In addition, the sound servers of old were really just mixers. In the old days most hardware was not capable of doing hardware mixing and thus couldn't produce sound from multiple apps at the same time, so a mixer was an essential component. Nowadays, software mixing is the norm rather than the exception, even on high end hardware, and ALSA itself has a pretty solid sofware mixing in the form of DMIX, thus obsoleting large parts of the previous sound server functionality - certainly making the additional features they did offer seem disproportionate to the hassle they introduced. In the early days DMIX was just another sound server. Apparently this has changed these days, no longer needing an additional process. While it achieves the job of software mixing very well, it's not as fast or as flexible as other solutions can offer.</p>
<h2>Modern Multi-user Desktop</h2>
<p>So, these days a modern, multi-user desktop is quite a different beast to what it once was. Components such as Console Kit track which users are currently active (e.g. when more than one user is logged in simultaneously) and tells udev to write appropriate ACLs to enforce this policy. Users also want to use network attached sound systems, such as Apple Airtunes (RAOP) devices and UPnP media renderers etc. not to mention Bluetooth devices. All of this is much further up the sound stack than the low level driver level and has to deal with various permission and authentication schemes. This obviously needs a userspace component to govern this interaction. Something has to be responsible for this and a "sound server" of some sort obviously fits the bill perfectly.</p>
<h2>PulseAudio</h2>
<p>So enter PulseAudio. It's had it's fair share of bad publicity, but ultimately this important part of the Linux sound stack is taking on several roles that are important in a modern desktop. It's dealing with several different things:</p>
<ul>
<li>Software mixing</li>
<li>Independent (per-application) volume control</li>
<li>Dealing with permissions (is the user allowed to access the sound device?)</li>
<li>Dealing with Bluetooth devices</li>
<li>Dealing with Network based devices (UPnP, Apple Airtunes, Native PulseAudio etc).</li>
<li>Handling the moving of streams between outputs.</li>
<li>Handling sound from remote applications run via X11 over a network.</li>
<li>Dealing with routing policy (Music goes to USB speakers, Desktop sound events to built in speakers, VoIP to Bluetooth headset)</li>
<li>Effects to promote HCI (e.g. positional event sounds  - button clicks etc, coming out louder on the left hand speaker when triggered from the left hand side of the desktop)</li>
<li>Power Consumption and Efficient savings.</li>
<li>Reduces risk of buffer under-runs.</li>
</ul>
<p>So the people who talk about OSSv4 and how it can do mixing and per-app volume control and how this means that ALSA and PulseAudio are not needed are totally underestimating what's needed in a modern audio stack. There still needs to be some kind of userspace daemon to govern these other sound systems and deal with multiple users. This is a non-trivial job and no other system out there is currently aiming to implement these capabilities.</p>
<p>One of the often overlooked advantages of PulseAudio is the "<a href="http://0pointer.de/blog/projects/pulse-glitch-free.html">glitch free</a>" system. This is an approach that ultimately disabled interrupt driven audio and instead relies on system timers. Modern kernels can provide these timers easily and reducing the number of interrupts and using larger buffers allows you to greatly reduce the number of CPU wake-ups thus saving power. This is actually a very important technique to implement when dealing with modern mobile platforms.</p>
<h2>Reuse</h2>
<p>It's obviously important to ensure efficient code reuse. It doesn't make sense for all sound producing applications to implement direct support for "exotic" sound systems such as Bluetooth, UPnP and Apple Airtunes etc. To do so is very inefficient (there are some exceptions to this - e.g. a media player that targets Win/Lin/Mac will maybe need to implement direct support if it is to be available across the board). Keeping the implementation centralised and having a single app-&gt;sound system API is essential here.</p>
<h2>Consistency of UI</h2>
<p>One of my big problems with many applications is inconsistent UI. This is a problem on Windows as much as on Linux, but it's something OSX has done mostly right. Users got to a central GUI to configure their sound and which device is currently active/in use. In Linux land all sound producing apps have their own config GUI for selecting sound devices. This is insane. Non-technical users don't know that you have to go to Tool-&gt;Preferences-&gt;Advanced-&gt;Sound in App A and Edit-&gt;Settings-&gt;Audio in App B. Sure, those of us who are reasonably technical will generally find the options (that's how we use applications - we click and look at all the settings pretty early on!), it's going to be less than obvious for a massive number of users. Keeping the preferences centralised so the user always know where to look is important and for a general purpose application that outputs sound, there should be no reason to provide any config option relating to this to the user - it should "just work"(tm).</p>
<h2>Incompatibility</h2>
<p>Some users have complained that some proprietary applications have stopped working with PulseAudio, Skype being an oft mentioned example. Well, I'm sorry but that's just tough. If a closed source application does not implement an API cleanly and does bizarre things, there is nothing we can do to fix it. The problems Skype has experienced with PulseAudio would also be experienced by any other plugin to ALSA. I'm sorry to say it, but in order to move forward, some applications have to suffer and/or be forced into action. By not allowing the people who care about this stuff the right to improve things themselves you're taking on the responsibility to do this yourself and you need to live up to your responsibilities. Considering the last version of Skype for Linux was released more than one and a half years ago, it's hard to consider it as anything more than abandon-ware at present. Will there be more pain like this? Yes, probably but that's just way things are - Free Software only truly works if the whole bundle is Free, if you mix and match you, as a user, have to accept this state of affairs. I do.</p>
<p>Desktop environments need to ensure they integrate nicely with PulseAudio. GNOME is obviously doing this, but KDE is lagging behind. I do hope to rectify the latter situation personally, and have a pretty clear roadmap to making this happen - it's just a matter of finding the time to do it!</p>
<h2>Conclusion</h2>
<p>So, with all this in mind, the sound stack has to be more than just a driver layer. It needs a persistent userspace layer that can run and keep track of various permission problems, deal with network connections and generally govern things. At present PulseAudio is fitting the bill pretty nicely and is continuing to add support for additional constructs in the Linux stack. As things stand all the major Linux distributions are now using PulseAudio with commercial interest from Nokia, Intel and Palm among others.</p>
<h2>Future</h2>
<p>So the future? Well, the drivers in ALSA need to be further debugged and developed to ensure the accuracy of the timing information that has so far plagued the "glitch free" system in PulseAudio. Nothing has pushed the ALSA drivers to such limits before, but the benefits of the glitch free mode are clearly worth the pain. Applications using the ALSA API need to ensure that they are using it correctly and sticking to the safe subset whenever possible (thus ensuring compatibility with PulseAudio's ALSA plugin). In addition, applications such as media players need to deal properly with latencies. It's a bit of a myth that low latencies are needed by such applications - higher latencies will ensure better battery life on mobile players and depending how the user wants to route their sound (e.g. to the Bluetooth enabled hi-fi system) latencies will be something beyond the control of the application in any event. It's therefore important to deal with this correctly and appropriately to ensure A/V sync. It's only been about half a year that the ALSA level limitations on buffer sizes were lifted after lobbying from the PulseAudio maintainer. Intel are even experimenting with 10 second buffers (that's not the same as latency!) in order to save power!</p>
<p>Every day more and more applications are tightening up their ALSA implementations. Every day the constructs of the Linux desktop are becoming more stable and solidified, offering a truly joined up multi-user and network aware experience. I think this is particularly impressive considering the fact that (as far as I know) only three people are employed to look after the Linux sound stack: Takashi Iwai andJaroslav Kysela on the ALSA side and Lennart Poettering on the PulseAudio side. While there are numerous other contributors, this is still pretty impressive progress with the resources at hand. It's also worth noting that two of the three are employed by RedHat, the other by Novell.</p>
<p>While Mandriva will still provide an easy way to disable PulseAudio if you feel it's not right for you (just untick the box - it's not hard!!) or need to use these closed applications such as Skype, I believe that this will not be necessary in the not too distant future.</p>
<p>So where is Sound on Linux? In my opinion it's in a pretty good state - there are still lots of things to do, and that will never change, but there is a firm and solid framework out there now and it's getting better every day.</p>
]]></content:encoded>
			<wfw:commentRss>http://colin.guthr.ie/2009/08/sound-on-linux-anti-fud-calm-certainty-and-confidence/feed/</wfw:commentRss>
		<slash:comments>35</slash:comments>
		</item>
		<item>
		<title>Sound on Linux is Confusing: Defuzzing Part 2: PulseAudio</title>
		<link>http://colin.guthr.ie/2009/08/sound-on-linux-is-confusing-defuzzing-part-2-pulseaudio/</link>
		<comments>http://colin.guthr.ie/2009/08/sound-on-linux-is-confusing-defuzzing-part-2-pulseaudio/#comments</comments>
		<pubDate>Sun, 02 Aug 2009 11:42:44 +0000</pubDate>
		<dc:creator>Colin</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[mandriva]]></category>
		<category><![CDATA[pulseaudio]]></category>
		<category><![CDATA[sound]]></category>

		<guid isPermaLink="false">http://colin.guthr.ie/?p=104</guid>
		<description><![CDATA[In an earlier article, I describe how the low level ALSA configuration allowed us to route all applications using the ALSA API via PulseAudio. In this article we'll take a look at the various configuration files and variables that control this side of the audio path.Let's walk through what happens when an application tries to [...]]]></description>
			<content:encoded><![CDATA[<p>In an <a href="http://colin.guthr.ie/2009/08/sound-on-linux-is-confusing-defuzzing-part-1-alsa/">earlier article</a>, I describe how the low level <a href="http://www.alsa-project.org/">ALSA</a> configuration allowed us to route all applications using the ALSA API via <a href="http://www.pulseaudio.org/">PulseAudio</a>. In this article we'll take a look at the various configuration files and variables that control this side of the audio path.<span id="more-104"></span>Let's walk through what happens when an application tries to play sound.</p>
<h2>ALSA Application</h2>
<p>So first off, an application using the ALSA API tries to open the "default" device. Assuming we've configured this default device to be the PulseAudio plugin for ALSA, it will basically act like every PulseAudio client application. We're now into the land of the PulseAudio configuration.</p>
<h2>PulseAudio Client</h2>
<p>PulseAudio adopts a client/server model that is very similar in principle to that of the X11 system. It is the server that actually outputs the audio and the client app that tells the server what to play. While this approach can be inefficient, resulting in the copying of audio data around, PulseAudio goes to great lengths to ensure that data copying and other latency-prone operations are kept to a minimum. In the common use case of both client and server running on the same machine, PulseAudio uses SHM (Shared Memory) to ensure that data sent from the client to server is not copied across the wire. The core of the PulseAudio server itself is "zero copy" meaning that <em>references</em> to the data are passed around without actually copying the data itself.</p>
<p>The first thing a PulseAudio client has to do is connect to a server. In order to do this, it checks various variables and configuration files to determine precisely to <strong>which</strong> server it will connect!</p>
<p>Initially, the PulseAudio client library looks for a <em>PULSE_SERVER</em> environment variable. If found, this variable can define a list of servers to which the client should connect. These servers can be specified as local UNIX sockets or DNS names/IP addresses for a TCP connection.</p>
<p>If this is variable does not exist or is empty, PulseAudio will then check for X11 properties on the root window. These properties are much like environment variables, but will be available remotely if you SSH to another machine with X11 forwarding. I'll speak about this more later. You can see a list of PulseAudio related properties by doing:</p>
<pre>xprop -root | grep PULSE</pre>
<p>The variables names used are the same as those used in the environment, so PulseAudio will look for a property called <em>PULSE_SERVER</em>.</p>
<p>Assuming it's still not got a server to connect to yet, PulseAudio will check for a <em>default-server</em> configuration in it's <em>client.conf</em> file. This file is located in either /etc/pulse/ or ~/.pulse/. Only one of the <em>client.conf</em> files is parsed. So if the user has their own one, the system one will <strong>not</strong> be parsed at all (this is a point I tried to make in vein on <a href="http://www.pulseaudio.org/ticket/606">PulseAudio bug #606</a> - it took quite a while for this to sink in as you can see!).</p>
<p>So we've tried three ways to find a server. If we've <em>still</em> not found one, we just resort to defaults - i.e. connecting to a local, personal daemon and a local system-wide daemon (system-wide use is generally not recommended, but is supported for certainly circumstances - typically embedded systems). If we <em>still</em> cannot connect, the <em>client.conf</em> file can specify whether or not we will try to automatically<strong> start</strong> a personal daemon. Since PulseAudio 0.9.11, this is the default behaviour and allows console applications to work out of the box without starting a PulseAudio deamon beforehand.</p>
<p>So, in the unlikely event that all that fails, we will ultimately not be able to play sound, but we've done pretty much everything we can to make it work! In order to better visualise this, let's look at a couple of typical scenarios and run through the above process.</p>
<h2>Console Application</h2>
<p>So, under a default install, we've booted to runlevel 3 and logged into the terminal. We don't set any special variables and start an application that plays sound via ALSA. Here is what happens.</p>
<ol>
<li>App opens default device</li>
<li>ALSA PulseAudio plugin (like any PulseAudio client) checks it's config for a server and finds none.</li>
<li>It tries to connect to a local server but fail as it is not running.</li>
<li>It then starts a PulseAudio server automatically and then connects to it.</li>
<li>The application then plays audio via the ALSA API functions and this is ultimately played by the PulseAudio daemon.</li>
<li>The client application finishes doing it's thing, and exits.</li>
<li>The PulseAudio daemon stays around for a while just incase another app wants to play sound in the near future.</li>
<li>After a while, the PulseAudio daemon will go in the huff because no one loves it and kill itself :p</li>
</ol>
<p>So that's it. It's quite simple. Let's have another example.</p>
<h2>X11 Application</h2>
<p>Under X11 things are a little bit different, but the same basic principles are followed.</p>
<ol>
<li>During X11 initialisation, modern desktops that support XDG Autostart ultimately run the script <em>start-pulseaudio-x11</em>. This script ensures the PulseAudio daemon is started and some extra X11 related modules loaded into it. These modules ensure that, unlike a console application, the X11 PulseAudio daemon will not exit after an idle timeout - it will instead stick around for as long as the X11 session exists. It als ensures that the X11 Properties mentioned earlier are set - the reasons for will will become apparent in the next example.</li>
<li>When any PulseAudio client (be it an ALSA app via the ALSA PulseAudio plugin, or a native PulseAudio) is started it goes through it's "find a server routine". It will now stop this process when it reaches the X11 properties and use the info therein and connect to the server.</li>
<li>The client application then plays sound as before and ultimately finishes and extis.</li>
<li>The PulseAudio daemon doen't exit/kill itself as the X11 session is still going.</li>
</ol>
<p>So again, things are actually quite simple.</p>
<h2>Remote X11 Application</h2>
<p>One of the handiest things with X11 is the ability to connect to another machine on your network and run GUI applications and have them display on your local display. With PulseAudio, the sound is also heard on the local machine. Out of the box (for security reasons), remote connections are not enabled. To enable them, run <em>paprefs</em> and enable the option <em>Enable network access to local sound devices.</em> This is the only option needed for this example. It loads an additional module into the server that listens on TCP port 4713 for incoming connections. Obviously, it goes without saying that any firewall on the machine must allow connections to this port!</p>
<ol>
<li>User starts a normal X11 session and the <em>start-pulseaudio-x11</em> script ensures the X11 properties are set as in the previous example.</li>
<li>User then connects to another machine on his network via SSH and starts an audio player (e.g. RhythmBox, Amarok, etc.)</li>
<li>Even tho' the app is running remotely the visual display will be local.</li>
<li>When the app starts playing audio, the PulseAudio client portion will find the X11 properties that have been forwarded through the SSH connection.</li>
<li>The PulseAudio client will then connect <em>over TCP</em> to the PulseAudio server running on the user's local machine.</li>
<li>The User revels in the local display and audio the application provides.</li>
</ol>
<p>So as you can see, the use of the X11 properties has allowed us to piggy back on top of the X11 forwarding. It's not a totally clean connection as under SSH the X11 data will actually be tunnelled over a secure link handled by SSH itself, whereas all we are doing is telling the PulseAudio client where to connect directly, outside of any SSH tunnels. This means that while the display can work over a NATed system, the sound will not. This is fairly easily addressed, but we'd have to teach SSH about PulseAudio for this to work. The reason it works for X11 is because SSH is aware of, and has specific support for, X11. We're just piggy backing on this. That said, the current arrangement is "good enough" for most use cases.</p>
<p>So I hope this article has demystified how the PulseAudio client and server interact and the various configuration files/variables that come into play. If you have any questions, please ask in the comments and I'll endeavour to update the article.</p>
]]></content:encoded>
			<wfw:commentRss>http://colin.guthr.ie/2009/08/sound-on-linux-is-confusing-defuzzing-part-2-pulseaudio/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
	</channel>
</rss>
