[PATCH] Add libcanberra support to knotify (was Re: knotify and libcanberra Re: KDE Sound and Multimedia Plan)

Colin Guthrie gmane at colin.guthr.ie
Mon Dec 6 23:53:46 GMT 2010


'Twas brillig, and Ian Monroe at 01/12/10 18:22 did gyre and gimble:
> On Wed, Dec 1, 2010 at 11:40 AM, Colin Guthrie <gmane at colin.guthr.ie> wrote:
>> Hope I've not ranted too much :D
> 
> No, this sounds like a more useful thread. :)
> 
> Reusing existing technology rather then build our own -> sounds good
> to me. Having a phonon backend for libcanberra would solve the "what
> about Windows" problem of having kdebase-runtime depend on
> libcanberra.

Just for giggles, I've gone ahead and implemented libcanberra support in
knotify (I also found a leak when using knotify with an external player
that's been there for years but that's another story!)

The patch I'll attach here is pretty brutal. It comments out external
player and phonon support (primarily for testing purposes, but if
everything is pushed through canberra then this would be the case anyway).


Now a small note about the sample cache in libcanberra. As currently
implemented in libcanberra, this is only used for sounds in the FDO
sound theme spec. If you specify a specific filename, a cache will not
be used. IMO it would be fairly easy to modify libcanberra to allow
caching on filenames too (just generate a hash and use that as the key).


Anyway, in order to easily test caching, I implemented support for using
FDO sound theme names with knotify in this patch too. It's a bit of a
hack, but I say it's acceptable for now (certainly for testing and only
a couple lines of code anyway).

So with the patch applied, I triggered various event sounds. IMO, even
without the cache, it seemed faster and more responsive than with
phonon, but YMMV.

In order to test the FDO names, I opened up System Settings->
Applications and System Notifications and then chose Konsole and the
"Bell in Visible Session" option. For the "filename" I wrote:

sound-theme://message-new-instant

(I only picked this name as in my current sound theme,
bell-window-system is disabled :D) Obviously this sound cannot be played
directly via this UI with the little "Play" button, as it's implemented
separately to knotify (which is strange as path and searching logic has
to be reimplemented but that's another story).

I then opened Konsole and simply hit backspace. This triggers the bell
and the sound was played nicely and the file was cached in PA's sample
cache and obviously was played from this when it was next triggered.

So all in all, this works surprisingly nicely with a very minimal
implementation. I'm quite tempted to push this patch (along with a small
UI tweak) into Mandriva as both the alsa and pulseaudio canberra
backends should serve all users quite nicely even without a direct
phonon backend (which would be needed eventually for cross platform
support if this general approach is adopted - which I would expect to be
subject to some resistance!)

Anyway, comments/tests welcome (flames unwelcome but I'll be wearing my
asbestos underpants just in case :p) :)


Col


PS Not sure if there is a better way to get the static C callback inside
the NotifyBySound::Private namespace somehow (which would allow me to
connect signals nicely if Private become a QObject and had appropriate
signals defined). I had to add a public function to NotifyBySound to get
the results I needed but it's not as "clean" as I'd like.

-- 

Colin Guthrie
gmane(at)colin.guthr.ie
http://colin.guthr.ie/

Day Job:
  Tribalogic Limited [http://www.tribalogic.net/]
Open Source:
  Mageia Contributor [http://www.mageia.org/]
  PulseAudio Hacker [http://www.pulseaudio.org/]
  Trac Hacker [http://trac.edgewall.org/]
-------------- next part --------------
A non-text attachment was scrubbed...
Name: knotify-canberra.patch
Type: text/x-patch
Size: 6385 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-multimedia/attachments/20101206/c456efec/attachment.bin>
-------------- next part --------------
_______________________________________________
kde-multimedia mailing list
kde-multimedia at kde.org
https://mail.kde.org/mailman/listinfo/kde-multimedia


More information about the kde-multimedia mailing list