diff options
author | Jamieson Christian | 2002-12-05 21:45:55 +0000 |
---|---|---|
committer | Jamieson Christian | 2002-12-05 21:45:55 +0000 |
commit | 50b69cb2dbbffb0e067416aa7aca84833381b1a7 (patch) | |
tree | af92da7cf5eedafae1f15cf0be1c4745ee13bf9f /scumm | |
parent | 632f44a1a41a9da360dd1cac3e8cb3ff315527ca (diff) | |
download | scummvm-rg350-50b69cb2dbbffb0e067416aa7aca84833381b1a7.tar.gz scummvm-rg350-50b69cb2dbbffb0e067416aa7aca84833381b1a7.tar.bz2 scummvm-rg350-50b69cb2dbbffb0e067416aa7aca84833381b1a7.zip |
Fixed inappropriate expiration of sound resources,
which fixes concurrency issues esp. in PocketPC and MorphOS.
Stubbed SysEx command 2 (start of song) to get rid of annoying warning.
Changed MT-32 instrument warnings to fit on one (80-char) line.
svn-id: r5842
Diffstat (limited to 'scumm')
-rw-r--r-- | scumm/imuse.cpp | 42 | ||||
-rw-r--r-- | scumm/imuse.h | 1 | ||||
-rw-r--r-- | scumm/resource.cpp | 2 | ||||
-rw-r--r-- | scumm/sound.cpp | 33 | ||||
-rw-r--r-- | scumm/sound.h | 1 |
5 files changed, 67 insertions, 12 deletions
diff --git a/scumm/imuse.cpp b/scumm/imuse.cpp index 85ef24ed62..392a9740d2 100644 --- a/scumm/imuse.cpp +++ b/scumm/imuse.cpp @@ -103,6 +103,7 @@ public: int stop_sound(int sound) { in(); int ret = _target->stop_sound (sound); out(); return ret; } int stop_all_sounds() { in(); int ret = _target->stop_all_sounds(); out(); return ret; } int get_sound_status(int sound) { in(); int ret = _target->get_sound_status (sound); out(); return ret; } + bool get_sound_active(int sound) { in(); bool ret = _target->get_sound_active (sound); out(); return ret; } int32 do_command(int a, int b, int c, int d, int e, int f, int g, int h) { in(); int32 ret = _target->do_command (a,b,c,d,e,f,g,h); out(); return ret; } int clear_queue() { in(); int ret = _target->clear_queue(); out(); return ret; } void setBase(byte **base) { in(); _target->setBase (base); out(); } @@ -487,6 +488,7 @@ public: int stop_sound(int sound); int stop_all_sounds(); int get_sound_status(int sound); + bool get_sound_active(int sound); int32 do_command(int a, int b, int c, int d, int e, int f, int g, int h); int clear_queue(); void setBase(byte **base); @@ -715,14 +717,14 @@ byte *IMuseInternal::findTag(int sound, char *tag, int index) int32 size, pos; if (_base_sounds) { - // FIXME: This is a hack to make certain parts of Sam & Max work. - // It's a NASTY HACK because it has to specifically skip sound 1. - // For some reason (maybe a script parse bug?), sound 1 is being - // played at the very beginning (opening logo). Until this "fix", - // the sound was never found and thus never played. It SHOULDN'T - // be played. - if (!_base_sounds[sound] && (sound > 1 || g_scumm->_gameId != GID_SAMNMAX)) - g_scumm->ensureResourceLoaded (rtSound, sound); + // The following hack was commented out because calling + // ensureResourceLoaded() is not safe from within this + // function. TODO: Make sure all Sam & Max music still works + // without this hack. It's very likely that changes to the + // resource expiration process solved whatever S&M problem + // this hack was originally intended to address. +// if (!_base_sounds[sound] && (sound > 1 || g_scumm->_gameId != GID_SAMNMAX)) +// g_scumm->ensureResourceLoaded (rtSound, sound); ptr = _base_sounds[sound]; } @@ -1162,6 +1164,21 @@ int IMuseInternal::get_sound_status(int sound) return get_queue_sound_status(sound); } +// This is exactly the same as get_sound_status except that +// it treats sounds that are fading out just the same as +// other sounds. This is the method to use when determining +// what resources to expire from memory. +bool IMuseInternal::get_sound_active(int sound) +{ + int i; + Player *player; + for (i = ARRAYSIZE(_players), player = _players; i != 0; i--, player++) { + if (player->_active && player->_id == (uint16)sound) + return 1; + } + return (get_queue_sound_status(sound) != 0); +} + int IMuseInternal::get_queue_sound_status(int sound) { uint16 *a; @@ -2266,11 +2283,11 @@ void Player::parse_sysex(byte *p, uint len) return; } } - warning ("Could not find appropriate MT-32 program for GM program %d", (int) a); + warning ("Could not map MT-32 \"%s\" to GM %d", buf, (int) a); return; } } - warning ("Could not find appropriate GM program for MT-32 custom instrument \"%s\"", buf); + warning ("MT-32 instrument \"%s\" not supported yet", buf); } } else { warning ("Unknown SysEx manufacturer 0x%02X", (int) a); @@ -2334,7 +2351,10 @@ void Player::parse_sysex(byte *p, uint len) break; maybe_jump (p[0], p[1] - 1, (read_word (p + 2) - 1) * 4 + p[4], ((p[5] * _ticks_per_beat) >> 2) + p[6]); break; - + + case 2: // Start of song. Ignore for now. + break; + case 16: /* set instrument in part */ a = *p++ & 0x0F; if (_se->_hardware_type != *p++ && false) diff --git a/scumm/imuse.h b/scumm/imuse.h index 108dd33100..c313aa78e3 100644 --- a/scumm/imuse.h +++ b/scumm/imuse.h @@ -50,6 +50,7 @@ public: virtual int stop_sound(int sound) = 0; virtual int stop_all_sounds() = 0; virtual int get_sound_status(int sound) = 0; + virtual bool get_sound_active(int sound) = 0; virtual int32 do_command(int a, int b, int c, int d, int e, int f, int g, int h) = 0; virtual int clear_queue() = 0; virtual void setBase(byte **base) = 0; diff --git a/scumm/resource.cpp b/scumm/resource.cpp index a2630fbf09..7129547c98 100644 --- a/scumm/resource.cpp +++ b/scumm/resource.cpp @@ -1356,7 +1356,7 @@ bool Scumm::isResourceInUse(int type, int i) case rtCostume: return isCostumeInUse(i); case rtSound: - return _sound->isSoundRunning(i) != 0; + return _sound->isSoundActive(i); default: return false; } diff --git a/scumm/sound.cpp b/scumm/sound.cpp index dec8eb0aff..3e1c24aac7 100644 --- a/scumm/sound.cpp +++ b/scumm/sound.cpp @@ -587,6 +587,39 @@ int Sound::isSoundRunning(int sound) { return se->get_sound_status(sound); } +// This is exactly the same as isSoundRunning except that it +// calls IMuse::get_sound_active() instead of IMuse::get_sound_status(). +// This is necessary when determining what resources to +// expire from memory. +bool Sound::isSoundActive(int sound) { + IMuse *se; + int i; + + if (sound == _scumm->current_cd_sound) + return pollCD() != 0; + + i = _soundQue2Pos; + while (i--) { + if (_soundQue2[i] == sound) + return true; + } + + if (isSoundInQueue(sound)) + return true; + + if (!_scumm->isResourceLoaded(rtSound, sound)) + return false; + + if (_scumm->_imuseDigital) { + return _scumm->_imuseDigital->getSoundStatus(sound) != 0; + } + + se = _scumm->_imuse; + if (!se) + return false; + return se->get_sound_active(sound); +} + bool Sound::isSoundInQueue(int sound) { int i = 0, j, num; int16 table[16]; diff --git a/scumm/sound.h b/scumm/sound.h index 50fb655e05..64904baf8d 100644 --- a/scumm/sound.h +++ b/scumm/sound.h @@ -144,6 +144,7 @@ public: void stopTalkSound(); bool isMouthSyncOff(uint pos); int isSoundRunning(int sound); + bool isSoundActive(int sound); bool isSoundInQueue(int sound); void stopSound(int a); void stopAllSounds(); |