Confusion over audio device enumeration
Colin Guthrie
phonon at colin.guthr.ie
Wed Sep 23 16:21:00 CEST 2009
Hi there
I'm just adding some more intelligence to phonon/kde with regards to
pulseaudio (for background, see the end of this mail).
It's been a while since I looked at the code and I'm just about back up
to speed but I've hit a bit of a brick wall with one particular part and
I figured I'd ask here in the hope that someone knows more than me :D
The problem I'm having revolves around platform plugins for phonon with
regards to device enumeration.
The two files in question are:
http://websvn.kde.org/trunk/kdesupport/phonon/phonon/globalconfig.cpp?view=markup#l130
http://websvn.kde.org/trunk/KDE/kdebase/runtime/phonon/kcm/globalconfig.cpp?view=markup#l121
Not both functions look quite similar but this is where I'm confused :s
So the platform plugin (second link) provides both it's own devices and
ask the backend. But the backend (first link) also appears to ask the
platform plugin for it's devices as well as giving it's own too.
I'm not really sure what's going on there, but I get the feeling things
should be tidied up in some capacity...
From what I can tell, loading up systemsettings->Multimedia in KDE does
not call the backend's globalconfig.cpp to display it's list of devices,
instead relying on the one from the platform plugin. But when a sound is
played (e.g. hit the "Test" button), the backend's globalconfig.cpp is
used (presumably to route the audio).
Can anyone shed light on this?
Cheers
Col
Background:
I'm a pulseaudio hacker and general cross desktop person. I generally
flit around between gnome and kde in some capacity and generally like to
see things interoperate as much as possible (i.e. shared trash handling,
shared application notification frameworks, shared sound event and icon
themes etc.)
I quite like the concept of phonon and can see it's value from a cross
platform perspective (with quicktime backend on OSX and dx on windows
etc.) but am a little disappointed that there are several linux backends
- personally I'd prefer to see efforts concentrated on one backend
(personally, from a technical design and appropriateness perspective, I
believe this should be gstreamer but I don't want to get into a
religious war so I wont hammer the point!)
In Mandriva we've shipped PulseAudio by default for the last few
releases. If pulseaudio is in use the priority list as shown in
systemsettings->Multimedia made very little sense. We've therefore
patched phonon/kdebase-runtime to hide all "devices" other than the
PulseAudio plugin in the list. Users can then use pavucontrol to move
the streams around to different devices for each applications as they
see fit.
This worked fairly well but obviously makes the GUI pretty much
pointless. Also out patches are tied to our own config files and
therefore cannot be pushed upstream.
So I've spent the last few days cleaning up the patches and detecting
pulseaudio in a more appropriate/programatic way (e.g. by trying to
connect!) which separates things from Mandriva specific configs and thus
allowing them to be upstreamed.
I've also spent quite some time developing a pulseaudio module called
module-device-manager. This module can be loaded into the pulseaudio
server and will do the following:
* Keep track of all sinks and sources seen on the server (including
Apple Airtunes, uPnP media renderers, Bluetooth headsets and hifis etc.)
* A protocol extension that allows this full list of devices to be
queried (pulse can give you a list of the *current* devices easily but
this extension keeps information for devices not currently plugged in
(e.g. USB, bluetooth, network etc.))
* For each device and for each role (cf. Phonon Category) it maintains
a priority list and can route audio to the approriate device based on
this information.
* Provides protocol extension to allow the editing of this priority list.
So with this module loaded, it is able to implement the routing system
exposed by phonon.
My aim is to turn the GlobalConfig at the backend into a wrapper around
the information provided from the server and the prefer/defer commands
pushed out to pulseaudio via the above mentioned protocol extension.
This turns the phonon routing system into, essentially, a thin client
deferring all responsibility to pulseaudio.
The reason I took this approach is that being involved at the front line
for linux audio, I often get enquiries from users. They are often
confused that when setting preferred devices for Music in systemsettings
as to why e.g. lastfm-player does not honour this? This is of course
obvious for people who are familiar with KDE and Phonon: The
systemsettings config only applies to applications using Phonon. But if
we use pulseaudio in the way I am working towards, then *all*
applications will honour this configuration (pulse can determine most
applications' role automatically from the category in their .desktop file)
So I hope I've explained my reasoning and why I think this is ultimately
the right approach.
For reference my git repositories can be found here:
http://colin.guthr.ie/git/
My module-device-manager for pulse is found on this branch:
http://colin.guthr.ie/git/pulseaudio/log/?h=history
For the KDE/Phonon patches see the appropriate git repos at the above
URL and look at the "pulse" branches.
All the best
Col
--
+------------------------+
| Colin Guthrie |
+------------------------+
| http://colin.guthr.ie/ |
+------------------------+
More information about the Phonon-backends
mailing list