KDE + PulseAudio != Sucks
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 all the routing for us). This is an acceptable solution but it's far from ideal.
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!).
So how does it all work? Well The first step is module-device-manager. This is a pulseaudio module that does the following:
- Store all devices we've ever seen and keep track of their description and their icon.
- Provide a protocol extension to allow clients to query this database.
- Implement a per-role priority list for devices (again exposing it via the protocol)
- Implement a routing policy that will always uses the highest available device for streams with the relevant role.
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.
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).
All in all, this means that:
- All the sinks/sources from PulseAudio are shown in the System Settings -> Multimedia dialog
- You can order the devices and this will be honoured and saved to pulseaudio. Audio will be routed according to this preference.
- Devices that are unavailable will be shown greyed out.
- When devices appear/disappear, they will be automatically used if they are higher up the priority list than what's currently being used.
But with all good news there is some bad news! So what's not working?
- 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.
- 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.
- Doesn't handle a PulseAudio restart (aka a crash and respawn!)
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!
And what is a blog post without a screenshot eh? OK here you go:
All my git repositories can be found here.










Pingback: Akari (akari) 's status on Friday, 02-Oct-09 00:18:11 UTC - Identi.ca()
Pingback: Lennart Poettering: Conferences | TuxWire : The Linux Blog()
Pingback: Lennart Poettering: Conferences | Full-Linux.com()
Pingback: So how does the KDE PulseAudio support work anyway? « Colin.Guthr.ie()
Pingback: MandrivaUser.de NEWS » KMix PulseAudio Integration()
Pingback: Mix it up « Colin.Guthr.ie()