mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-30 07:23:05 +00:00
proper fix for COMI timer issue: don't let a Timer remove itself
svn-id: r10867
This commit is contained in:
parent
012450de73
commit
96a8d0ec1c
@ -91,12 +91,10 @@ int Timer::handler(int t) {
|
||||
for (l = 0; l < MAX_TIMERS; l++) {
|
||||
if (_timerSlots[l].procedure && _timerSlots[l].interval > 0) {
|
||||
_timerSlots[l].counter -= interval;
|
||||
// FIXME: We only check the value of _timerSlots[l].interval here
|
||||
// because the timer might remove itself.
|
||||
// Strictly spoken, that is a dirty thing to do for a timer, but for
|
||||
// now the bundle timer requires this. Of course the whole bundle
|
||||
// music timer is kind of scary anyway...
|
||||
while (_timerSlots[l].counter <= 0 && _timerSlots[l].interval > 0) {
|
||||
while (_timerSlots[l].counter <= 0) {
|
||||
// A small paranoia check which catches the case where
|
||||
// a timer removes itself (which it never should do).
|
||||
assert(_timerSlots[l].procedure && _timerSlots[l].interval > 0);
|
||||
_timerSlots[l].counter += _timerSlots[l].interval;
|
||||
_timerSlots[l].procedure(_timerSlots[l].refCon);
|
||||
}
|
||||
|
@ -1011,8 +1011,9 @@ void Sound::playBundleMusic(const char *song) {
|
||||
}
|
||||
|
||||
if (_nameBundleMusic[0] == 0) {
|
||||
_outputMixerSize = 66150; // ((22050 * 2 * 2) / 4) * 3
|
||||
if (_scumm->_gameId == GID_CMI) {
|
||||
_outputMixerSize = (22050 * 2 * 2);
|
||||
|
||||
char bunfile[20];
|
||||
sprintf(bunfile, "musdisk%d.bun", _scumm->VAR(_scumm->VAR_CURRENTDISK));
|
||||
if (_musicDisk != _scumm->VAR(_scumm->VAR_CURRENTDISK))
|
||||
@ -1026,8 +1027,9 @@ void Sound::playBundleMusic(const char *song) {
|
||||
}
|
||||
|
||||
_musicDisk = (byte)_scumm->VAR(_scumm->VAR_CURRENTDISK);
|
||||
_outputMixerSize = 88140; // ((22050 * 2 * 2)
|
||||
} else {
|
||||
_outputMixerSize = ((22050 * 2 * 2) / 4) * 3;
|
||||
|
||||
if (_bundle->openMusicFile("digmusic.bun", _scumm->getGameDataPath()) == false)
|
||||
return;
|
||||
}
|
||||
@ -1038,17 +1040,13 @@ void Sound::playBundleMusic(const char *song) {
|
||||
_offsetBufBundleMusic = 0;
|
||||
_bundleMusicPosition = 0;
|
||||
_pauseBundleMusic = false;
|
||||
_musicBundleToBeRemoved = false;
|
||||
_musicBundleToBeChanged = false;
|
||||
_bundleMusicTrack = 0;
|
||||
_numberSamplesBundleMusic = _bundle->getNumberOfMusicSamplesByName(song);
|
||||
_nameBundleMusic = song;
|
||||
_scumm->_timer->installProcedure(&music_handler, 1000000, this);
|
||||
return;
|
||||
}
|
||||
if (strcmp(_nameBundleMusic, song) != 0) {
|
||||
} else if (strcmp(_nameBundleMusic, song) != 0) {
|
||||
_newNameBundleMusic = song;
|
||||
_musicBundleToBeRemoved = false;
|
||||
_musicBundleToBeChanged = true;
|
||||
}
|
||||
}
|
||||
@ -1058,7 +1056,18 @@ void Sound::pauseBundleMusic(bool state) {
|
||||
}
|
||||
|
||||
void Sound::stopBundleMusic() {
|
||||
_musicBundleToBeRemoved = true;
|
||||
// First stop the music timer
|
||||
_scumm->_timer->releaseProcedure(&music_handler);
|
||||
_nameBundleMusic = "";
|
||||
_scumm->_mixer->stopChannel(_bundleMusicTrack);
|
||||
if (_musicBundleBufFinal) {
|
||||
free(_musicBundleBufFinal);
|
||||
_musicBundleBufFinal = NULL;
|
||||
}
|
||||
if (_musicBundleBufOutput) {
|
||||
free(_musicBundleBufOutput);
|
||||
_musicBundleBufOutput = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void Sound::bundleMusicHandler(ScummEngine *scumm) {
|
||||
@ -1070,21 +1079,6 @@ void Sound::bundleMusicHandler(ScummEngine *scumm) {
|
||||
if (_pauseBundleMusic)
|
||||
return;
|
||||
|
||||
if (_musicBundleToBeRemoved) {
|
||||
_scumm->_timer->releaseProcedure(&music_handler);
|
||||
_nameBundleMusic = "";
|
||||
_scumm->_mixer->stopChannel(_bundleMusicTrack);
|
||||
if (_musicBundleBufFinal) {
|
||||
free(_musicBundleBufFinal);
|
||||
_musicBundleBufFinal = NULL;
|
||||
}
|
||||
if (_musicBundleBufOutput) {
|
||||
free(_musicBundleBufOutput);
|
||||
_musicBundleBufOutput = NULL;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (_musicBundleToBeChanged) {
|
||||
_nameBundleMusic = _newNameBundleMusic;
|
||||
_numberSamplesBundleMusic = _bundle->getNumberOfMusicSamplesByName(_nameBundleMusic);
|
||||
@ -1104,9 +1098,7 @@ void Sound::bundleMusicHandler(ScummEngine *scumm) {
|
||||
if (l == 0) {
|
||||
tag = READ_BE_UINT32(ptr); ptr += 4;
|
||||
if (tag != MKID_BE('iMUS')) {
|
||||
warning("Decompression of bundle song failed");
|
||||
_musicBundleToBeRemoved = true;
|
||||
return;
|
||||
error("Decompressing bundle song failed (unknown tag '%s')", tag2str(tag));
|
||||
}
|
||||
|
||||
ptr += 12;
|
||||
@ -1139,9 +1131,7 @@ void Sound::bundleMusicHandler(ScummEngine *scumm) {
|
||||
}
|
||||
}
|
||||
if (size < 0) {
|
||||
warning("Decompression sound failed (no size field)");
|
||||
_musicBundleToBeRemoved = true;
|
||||
return;
|
||||
error("Decompressing sound failed (missing size field)");
|
||||
}
|
||||
header_size = (ptr - _musicBundleBufOutput);
|
||||
}
|
||||
|
@ -57,7 +57,6 @@ protected:
|
||||
bool _pauseBundleMusic;
|
||||
PlayingSoundHandle _bundleMusicTrack;
|
||||
bool _musicBundleToBeChanged;
|
||||
bool _musicBundleToBeRemoved;
|
||||
int32 _bundleMusicSampleBits;
|
||||
int32 _outputMixerSize;
|
||||
int32 _bundleSampleChannels;
|
||||
|
Loading…
x
Reference in New Issue
Block a user