Lennart Poettering did a pretty good job of going through the various sound APIs on Linux, he even made a diagram. It shows just how varied and complex the soundscape on Linux is.
Unfortunately for his readers, Lennart started riffing in places when he probably should have stuck to the topics he's familiar with. Given that it's me talking here, you can probably guess what the topics included ... yep, Phonon and KNotify.
For Phonon, Lennart said, "Use GStreamer! (Unless your focus is only KDE in which cases Phonon might be an alternative.)" Lennart works with GStreamer, so he will naturally lean towards it, but this statement is incorrect on many levels.
Phonon has only a Qt dependency, so if you are using Qt it's an option; KDE doesn't come into play in that decision. Many of our KDE4 libraries are like that these days actually. Phonon is also more than just an option for Qt apps: you'd be making a huge mistake not to use it. You see, Phonon gets you equal and native support on Windows and Mac as well without the user having to install, say, GStreamer.
But what if you only care about Linux? Phonon integrates well with the rest of your Qt code, makes it far simpler to use the underlying engine, and will happily backend onto GStreamer where it exists. But it also allows the user, system administrator or system integrator decide to use something else besides GStreamer. Or, should GStreamer fall out of favour in the future on Linux, you won't have to rewrite your code.
For event notifications, Lennart said, "Use libcanberra, install your sound files according to the XDG Sound Theming/Naming Specifications! (Unless your focus is only KDE in which case KNotify might be an alternative although it has a different focus.)"
This is the classic "event notifications are about sound" mistake. KNotify is a generic notifications framework that lets you create notifications, in the abstract sense, and then let the framework sort out whether they should be played as sounds, logged to files, etc. Sound is just one aspect of notifications, and providing a centralized mechanism to manage notifications is a (excuse the pun) sound design.
Note also how Lennart used the phrase "Unless your focus is only KDE" twice. What does that actually mean? Honestly: nothing meaningful, though bordering on FUD. That phrase might literally mean (and I'm being gracious here) "If you are use KDE libraries to develop your application." (Yes, it's for Qt-only apps too, as we already know) But what many will probably read it as is this: "If you intend your application to be run only in a KDE desktop ..." That's just wrong ... those frameworks are for use with applications that use Qt and/or KDE libraries. No more, no less and nothing about what one's focus is.
This does bring us back to that blog entry from a few days back about clarifying the KDE brand: in this case it would've made Lennart's characterization of Phonon and Knotify less ambiguous (even if still inaccurate).
Lennart does point out a couple of shortcomings of KNotify: "However it does not support the XDG Sound Theming/Naming Specifications at this point, and also doesn't support caching or passing of event meta-data to an underlying sound system." The sound theme spec thing is a bit lame because it's a brand new spec (GNOME only recently picked it up in their release that was made today) and in typical xdg spec fashion is essentially documentation of one implementation. Others will likely follow, so give it time. The caching bit really has more to do with the sound subsystem, and passing of meta data down into the media layer isn't done either. So I do give him some points there; places we can improve KNotify.
Lennart later says, "Phonon and KNotify should only be used in KDE/Qt applications and only for high-level media playback, resp. simple audio notifications." This makes them sound like toys, and while I won't say that Phonon is what you'd want for a high end pro-audio engineering tool, if you look at apps like Amarok2 its pretty obvious that these libraries are rather above the "toy" status.
So when do you want to use Phonon? When you aren't doing high end pro-audio stuff and need to play audio or video (capture will be there soon as well, I see code in the experimental/ folder already) and you want it to work today and tomorrow on Linux, BSD, Solaris, Windows and Mac using the native facilities. Phonon alone may be reason enough to use Qt in your application, in fact, if only just for multimedia features in your application.
When do you want to use KNotify? When you are writing code that uses the KDE libraries and you want to notify the user of something.
To Lennart: you know a lot about audio on Linux. Thanks for your contributions to FOSS and those explanations on your blog of the various audio bits and knobbles in Linuxland. But do everyone a favor and stick to the parts you actually know: you'll look smarter when someone like me doesn't come along and correct you (so you win) and others won't be misled in a blind-leading-the-blind scenario (so your community wins). If you do want to write about Phonon or other Qt/KDE technologies on your blog, I'd be happy to field questions for you as part of your due diligence research.
Thursday, September 25, 2008
Subscribe to:
Post Comments (Atom)

18 comments:
Phonon is a pretty awesome piece of technology in abstracting a complex API and keeping ABI with a growing API and changing backends. Sometimes folks seem to think its more. Like I'd really have no problem with Phonon being presented as a little box on top of GStreamer in that diagram.
He presents Phonon as something like GStreamer, but "it supports multiple backends". I'd say the "multiple backend" part means that its nothing at all like GStreamer. Gstreamer is an backend.
So gstreamer (despite Lennart's implicit "like GStreamer" assumption) doesn't compete with Phonon, the obvious reason being: phonon-gst. Actually a very realistic solution is to have phonon-gst used on all platforms. From Amarok we know that having multiple backend options just means more maintenance work and little benefit. Which gets to the true point of Phonon: not to compete with GStreamer, but to future proof the KDE and Qt APIs.
I responded to a previous Phonon vs. gstreamer (as if they are direct competitors) awhile ago: LWN letter to the editor.
In all fairness if you're not using Qt/KDE you're probably using glib and descendants in which case it does make more sense to aim at gstreamer than to use gstreamer through Phonon.
As far as caching goes, I honestly don't see why they bother. Pretty much every useful operating system already caches files that are used automatically (which is why we refer to running benchmarks with a cold cache). I could see preloading a sound useful to avoid latency the first time it's played (or if it hasn't been played in awhile) but caching in general means you're just wasting memory as the kernel is already caching the information in question.
Question: Qt has a Phonon dependency, but does Phonon have a Qt dependency?
If Phonon can be used just as easily with GTK apps as with Qt apps...that's an extremely useful sound library there. Maybe approaching the appearance of general-purposeness that's comparable to Apple's Core Audio.
@Ian, @mpyne: all good points...
@jud: Phonon has a Qt dependency (QtCore, QtGui and optionall QtDBus). you don't need to use the widgets, however, and with Qt's glib event loop you can use it inside glib based apps (e.g. Gtk+)
My main issue with Phonon at the moment is that it doesn't interact with Jack at all at this point. Not even by fudging things with the Alsa Jack plugin. This makes it impossible to play the new amarok through my soundcard which is currently supported by jack only.
(crap crap crap.. something went wrong with blogger's moderation tool, or maybe i click the wrong thing, and this comment didn't make it through.. ARG! my apologies to chrismurf.. =/)
chrismurf: You have it all wrong. The problem is not with Lennart's post, the
problem is that there are not more similar posts to choose from. High-level introductions to sections of the linux world (like audio)
are hard to come by, and incredibly useful to new developers (like me).
I don't doubt Lennart's post is imperfect, but it is an excellent place
to start. If there were alternate, equally useful posts, reading those
would be equally valuable. Writing documentation is hard, writing
high-level guidance is harder.
@chrismurf: "The problem is not with Lennart's post, the
problem is that there are not more similar posts to choose from."
i don't think those two things are mutually excusive:
Lennart's post is mostly good (and i thanked him for his efforts) but also contains some highly inaccurate and misleading bias. so yes, there is a problem with his post.
that said, it also great that he's writing high level documentation like that. KDE believes in those efforts strongly, to the point we have set up Techbase (http://techbase.kde.org) and spend considerable resources on it.
Before criticizing other's arguments, you might want to weigh your own arguments that you are going to use to support your criticism:
http://blogs.gnome.org/uraeus/2008/09/25/in-the-land-of-silly-arguments/
@zeenix: see my comment on Christian's blog entry there. his posting is as misinformed and confused as Lennart's when it comes to Phonon.
I am completely lost by the Gnome Pro-Gstreamer lot's campaign. They seem to be under the illusion that if they have a preference then that applies to the rest of the community. It may just be that I don't use Gstreamer as it is currently inferior to Xine, Mplayer and VLC (Obviously I mean at playback). If that changes then I shall change my Phonon backend but as things stand I prefer my avi collection to playback with out green quadrangles down the right hand side of the screen and as VLC, MPlayer and Xine offers a non green quadrangle playback feature then I shall stick with them.
No I will not log faults for GStreamer as I am not particularily interested in seeing it succeed, if that changes then I shall do my bit.
Thanks for finding my post despite blog issues, and the reasoned response. I'm happy to see the improved documentation efforts on all sides -- I'll look at techbase, as I'm mainly familiar with the G-side of things.
Phonon has only a Qt dependency
Here is the problem. GStreamer doesn't depend on GTK+, and Qt depends on GLib anyway. So GStreamer is more generic.
It might be worth adding a clarification on Christian's followup post for the sake of comments like (regarding “Phonon is also more than just an option for Qt apps”):
At first, my reading was : “Phonon is not only for Qt apps, it’s an option for all application”
Then, I read it again and I understood : “For Qt apps, and only Qt apps, Phonon is more than an option, it’s THE solution.”
Even just a quick confirmation might lead to less like:
Don’t be so naive, is not the first time Aaron’s mouth get him into trouble, some how every time I hear from this guy is because a rant or a controversy, So till he doesn’t explain what did he want to say then I’ll take it like he was refering to phonon beyond Qt. And this is because his bad reputation.
@vakhitov: which is 100% irrelevant for apps that use Qt, isn't it?
@Aneurin: that is an interpretation others have made, not what i wrote or said. i really don't have the ability (read: time or energy) to be able to fix everyone's mistakes.
to be honest, such people as you quote there are not the audience i care about. i'm not actually trying to correct or convince such people (who are free to be as enlightened or not as they wish to be), i'm trying to prevent their addled conclusions from tainting the broader audience of reasonable people who don't harbour personal bias like a chip on their shoulder.
I'm still lost on this one as it seems arguing over minor implementation details is a coders blinkered view of the world. If there was to be an argument it would be over what Phonon achieves. Coding for GStreamer would be sensible if it was the dominant media framework on merit but as it isn't and in my mind inferior to the competition (competition to which it is much older yet less mature (my opinion and others)) then there is no argument to be had.
Audio API wars!
Only on GNU/Linux!!
@vakhitov: Actually, Qt's GLib support is optional, not required.
I wonder, if Phonon were to allow the same app to use multiple backends simultaneously, and if there was a way for Phonon to check what functionality is supported by each backend, then Phonon would be able to include stuff that isn't common to all multimedia frameworks. Then if an app tries to access functionality that isn't supported by the current backend, Phonon will be able to find and use a different backend just for that functionality.
Post a Comment