getElapsedTime() for sounds
|Reported by:||eriktorbjorn||Owned by:||eriktorbjorn|
|Cc:||Game:||Broken Sword 1|
This patch adds the getElapsedTime() function that we discussed recently.
I had originally envisioned it as being part of the AudioStream class, but that turned out to be impractical for several reasons. Most importantly, the mixer may call readBuffer() several times in rapid succession in order to buffer up sound, which made it hard to get a reliable value for the number of samples that had actually been consumed. Instead, it is now part of the Channel class, and accessed through a method in the SoundMixer class.
Converting the Broken Sword cutscene animation to use this function instead of the current method should be trivial. (I did it for half of the BS2 code for a test case, but that isn't included in the patch.)
If this patch is accepted, we can probably get rid of getSamplesPlayed(). I think it's only used by the Broken Sword games, and it's not working very well.
There are a few things in the code that could probably be cleaned up a bit. For instance, getElapsedTime() needs to access the get_msecs() function, and currently does so through g_system.
Also, there is nothing to handle the case where sound is paused.
Ticket imported from: #892455. Ticket imported from: patches/426.