Fixed exit door in the7colors, where the frame had a looping
birds chirping sound together with the following Lingo:
if the soundbusy of 2 then go to the frame
And that led to an infinite loop and inability to pass through the
opened door.
The original apparently is returning 0 in-between the sound loops
since it manually restarts the sound after its completion. We, in
contrast, are optimizing that and using LoopedAudioStream
since f48dbb43b6
playStream() is called right after setting loopPtr, which was leading
to immediate reset of loopPtr. Thus, we were not able to control
the looping sounds
It's possible for audio playback to still be underway at the time the
AudioFileDecoder is destroyed. For Mac games, destroying the _macresman
will also destroy the stream, feeing the pointer while it may be read from
in another thread. Copying the audio instead of just fetching the stream
from the MacResMan ensures that new stream will outlive the MacResMan if
necessary.
Fixes https://bugs.scummvm.org/ticket/13881.
Lingo function `closeResFile` is only responsible for closing resource
file opened by `openResFile`. Register in `openResFile` which files
where opened and close only those files in `closeResFile`.
- Rename `_openResFiles` to `_allOpenResFiles` and
- Add new `_openResFiles` hashmap to track which files were opened in
`openResFile`.
For looping sounds, the original code polled the score and created a new
AudioStream every time the previous iteration finished playing. The
downside of this approach is the sound needs to be fully resampled and
buffered after each playback, which can be heard as a gap between loops.
To fix this, loops now use a LoopableAudioStream. The reason why the
previous code did not was to allow for a specific edge case.
In Director, when a looping audio channel is set to cast member 0, the
loop is allowed to finish the current iteration before the audio stops.
Originally there wasn't a way of doing that, but now the
LoopableAudioStream classes can stop playing after a number of
iterations. As such, we keep a copy of the LoopableAudioStream handle
and call for the loop to stop when the cast member gets set to 0.
Improves looped audio playback in Eastern Mind.
Fixes the guitar solo between the transition from BLAST.DXR to INTRO.DXR
in Meet MediaBand.
Fixes the audio transition between n.am and s.am in Meet MediaBand.
Most variants of puppetSounds don't actually start the sound immediately
but wait until the frame is updated. So I've created a SoundID struct
which stores a reference to a cast member or externals sound, and that
is used to store the puppetSound until it's actually supposed to start.
In addition, puppet status is now per-channel instead of a universal
flag.
A call to AudioFileDecoder::getAudioStream() was missed during the
refactor in 682d2dbb6c, meaning that any
sound invoked by "sound playFile" would loop.
Fixes the narration text in Chop Suey (e.g. TABLE.DIR) from looping and
being unable to progress.
We should only check if the last sound we saw in this channel is the
same, not if playback of the sound has ended. Otherwise, this can cause
a sound to incorrectly loop like in Meet Mediaband.