[Kde-games-devel] Re: TagaroAudio Bugfix

Ian Wadham iandw.au at gmail.com
Sat Jun 18 02:03:48 CEST 2011


On Saturday 18 June 2011 6:06:46 am Mathias Kraus wrote:
> there is a bug in TagaroAudio which leads to mute sound. The bug is
>  triggered after the same sound is played 256 times.
>
Heh!  I ran into that one on day one of using TagaroAudio in KGoldrunner!
KGr does not play with footstep sounds for very many seconds before it
falls silent.  Is it really a limit of 256 or just RAM filling up?  Whatever,
but I think the Tagaro API doco needs to stress more strongly that
Tagaro::Sound::start() creates object(s) and there is no automatic
deletion when the sound finishes playing.

> Every time a sound is played, an AlSource is created but never deleted.
> I have a bugfix/workaround which tests if the source is valid and uses that
> source instead of creating a new one. The drawback is, that the playback
>  from that source is stopped (if running) and immediately starts from the
>  beginning. In the case there is no position specified for the playback,
>  there is not much difference to the previous perception. But if there is a
>  position specified, it might sound bad.
>
My first solution was to do Tagaro::Sound::stop() before every
Tagaro::Sound::start(), but as you say that can cut off an earlier
instance of a sound that might still be playing.  In KGr's case, rapid
sequences of dig or gold sounds can overlap.  So I kept a record
of the start time of such sounds and and avoided using Tagaro::Sound::
stop() on those sounds until a certain time had elapsed after the last one
started.  Not very elegant, but it works ... :-)

> As I don't use positional playback in granatier, the bugfix is sufficient
>  for my needs, but I have to found a proper one with the help from Stefan.
>  I know from at least KGoldrunner to also use TagaroAudio, so please port
>  the bugfix (commit 1237315) to your copy of TagaroAudio if you encounter
>  the same problem.
> 
Yes.  I like the beautiful simplicity of Tagaro::Sound::start() and
Tagaro::Sound::stop(), because they relieve the programmer of the worry
of keeping track of what is currently playing and how long each sound
plays (even if he knows that).  In many games there might be very little
risk of sounds of the same type overlapping.

What I looked for, but could not find, neither in TagaroAudio nor in OpenAL
doco, was some kind of feedback of what has happened to a sound after
it has been started: either a status-check (Is any sound of this type still
playing?) or an an interrupt (a signal and slot?) on completion.  If I had
found something like that, I could have patched TagaroAudio ... :-)

I guess it would be nice, too, if TagaroAudio could automatically delete
instances of sounds after they have finished playing.

And maybe, for the future, a finer control over individual instances of sounds
will be needed (e.g. the train on the left is rattling towards you [increasing
volume] and the one on the right is moving away [decreasing volume]).  At
present, TagaroAudio operates on all sounds of a particular type
(e.g. rattling train).

Ideas, Stefan?

All the best, Ian W.

P.S. If a game pauses, sounds must stop but there is no easy way to
continue them when the game resumes.  This is a minor problem,
so a solution would be in the "nice to have" category.


More information about the kde-games-devel mailing list