[Kde-games-devel] Junior job not only for GSoCers: Low-latency sound playback with KgSound

Ian Wadham iandw.au at gmail.com
Wed Mar 21 08:17:49 UTC 2012


On 21/03/2012, at 10:03 AM, Roney Gomes wrote:

>>> On 03/18/2012 01:50 AM, Ian Wadham wrote:
>> At a very quick glance, the code looks OK, so maybe it is something missing in your environment.  You need:
>>    - Hardware/OS sound turned on,
>>    - Sound setting on in Kapman Settings menu,
>>    - OpenAL library installed,
>>    - LibSndFile library installed,
>>    - Sound files installed in your $KDEDIR area (Is KStandardDirs::locate finding any files?),
>>    - Any other "obvious" things.
>> 
>> If you do not have both libraries, I think KgSound will default to Phonon, which might or might not play OK.
>> 
>> If all the above things seem OK, try making the problem smaller, e.g. have a few lines of code that just play
>> *one* sound, such as bonus.ogg, at a moment of your choosing.  Oh, and did the game play sounds before
>> you started to change the code?
>> 
>> Happy hunting!
> 
> Yay, I solved the problem. :D

Heh, heh … there is nothing quite like that forehead-slapping moment …

> There are no bugs in the code, everything is fine. It is my environment that is not properly configured.

Never say there are no bugs in some code.  Remember Dijkstra ...

> In the calls to KgSound's constructor instead of passing "sounds/foo.ogg" as argument, I passed the entire path to the file and everything is working.

In fact, there's a bug right there!  By brute force, you got it to work, but the intent of
KStandardDirs::locate is that it should find files of a required type ("sound" in this
case) in ANY configuration.  On my Macbook, the Macports package installation
for KDE Games puts the Kapman sounds in /opt/local/share/sounds/kapman, but
I expect the filepath is very different for you.

> I guess there is something wrong with my $KDEDIR variable, I tried to set some values
> to it but they haven't worked. How do I fix it?

i do not know for sure.  I do not have second sight and cannot see into your computer … :-)

The idea of the $KDEDIR environment variable (and several other such variables) is to allow you to
test with executables, data files, temp files, libraries, config files, etc. in places different from where
your distro puts your released versions of KDE and Qt and different from the the locations of data
files, temp files, config files, etc. those released versions use.

To get some idea of this, have a look at $HOME/.kde4.  That stuff gets created automatically BTW.

Also, somewhere like /usr/share/kde4 might be where to find the released data files for most apps.
On my Linux system (OpenSUSE) I see that Kapman sounds were installed in /usr/share/sounds,
along with the KDE System sounds, which is different from what other games do.  All this structure
of where things go gets handled automatically by cmake, make and make install.  $KDEDIR and
other variables just change the base or "prefix" of the various KDE and Qt directories.

Hope this helps, Ian W.




More information about the kde-games-devel mailing list