From 72a020320f1e9e5b9b4d6c99b95fc93cc126e440 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sun, 3 Jan 2010 13:28:59 +0000 Subject: SCI/new music code: - sounds are no longer stopped in cmdUpdateCues if their signal is set - cmdSetSoundVolume no longer throws a warning if it can't find the associated sound (in some games, it's called before the actual sound is loaded) - removed unused parameters to the SciMusic() class and to MusicEntry::onTimer() - removed a hack to get the sound loop selector svn-id: r46923 --- engines/sci/sfx/music.cpp | 12 +++++------- engines/sci/sfx/music.h | 4 ++-- engines/sci/sfx/soundcmd.cpp | 10 +++++++--- 3 files changed, 14 insertions(+), 12 deletions(-) (limited to 'engines') diff --git a/engines/sci/sfx/music.cpp b/engines/sci/sfx/music.cpp index 9a2549eb11..92b83d97f2 100644 --- a/engines/sci/sfx/music.cpp +++ b/engines/sci/sfx/music.cpp @@ -37,7 +37,7 @@ namespace Sci { -SciMusic::SciMusic(ResourceManager *resMan, SegManager *segMan, SciVersion soundVersion) +SciMusic::SciMusic(SciVersion soundVersion) : _soundVersion(soundVersion), _soundOn(true) { // Reserve some space in the playlist, to avoid expensive insertion @@ -365,7 +365,7 @@ void SciMusic::soundInitSnd(MusicEntry *pSnd) { void SciMusic::onTimer() { const MusicList::iterator end = _playList.end(); for (MusicList::iterator i = _playList.begin(); i != end; ++i) - (*i)->onTimer(_soundVersion); + (*i)->onTimer(); } void SciMusic::soundPlay(MusicEntry *pSnd) { @@ -383,11 +383,9 @@ void SciMusic::soundPlay(MusicEntry *pSnd) { _mutex.unlock(); // unlock to perform mixer-related calls if (pSnd->pStreamAud && !_pMixer->isSoundHandleActive(pSnd->hCurrentAud)) { - SegManager *segMan = ((SciEngine *)g_engine)->getEngineState()->_segMan; // HACK - uint16 loop = GET_SEL32V(segMan, pSnd->soundObj, loop); // Are we supposed to loop the stream? - if (loop > 1) - pSnd->pStreamAud->setNumLoops(loop); + if (pSnd->loop > 1) + pSnd->pStreamAud->setNumLoops(pSnd->loop); else pSnd->pStreamAud->setNumLoops(1); _pMixer->playInputStream(pSnd->soundType, &pSnd->hCurrentAud, @@ -549,7 +547,7 @@ MusicEntry::MusicEntry() { MusicEntry::~MusicEntry() { } -void MusicEntry::onTimer(SciVersion soundVersion) { +void MusicEntry::onTimer() { if (status != kSoundPlaying) return; diff --git a/engines/sci/sfx/music.h b/engines/sci/sfx/music.h index 5f101ed39f..7f9bd413bc 100644 --- a/engines/sci/sfx/music.h +++ b/engines/sci/sfx/music.h @@ -112,7 +112,7 @@ public: ~MusicEntry(); void doFade(); - void onTimer(SciVersion soundVersion); + void onTimer(); #ifndef USE_OLD_MUSIC_FUNCTIONS virtual void saveLoadWithSerializer(Common::Serializer &ser); @@ -128,7 +128,7 @@ class SciMusic { public: - SciMusic(ResourceManager *resMan, SegManager *segMan, SciVersion soundVersion); + SciMusic(SciVersion soundVersion); ~SciMusic(); void init(); diff --git a/engines/sci/sfx/soundcmd.cpp b/engines/sci/sfx/soundcmd.cpp index fe1e1a1c06..24d63036b5 100644 --- a/engines/sci/sfx/soundcmd.cpp +++ b/engines/sci/sfx/soundcmd.cpp @@ -134,7 +134,7 @@ SoundCommandParser::SoundCommandParser(ResourceManager *resMan, SegManager *segM #endif #ifndef USE_OLD_MUSIC_FUNCTIONS - _music = new SciMusic(_resMan, _segMan, _soundVersion); + _music = new SciMusic(_soundVersion); _music->init(); #endif @@ -796,7 +796,7 @@ void SoundCommandParser::cmdUpdateCues(reg_t obj, int16 value) { } break; case SIGNAL_OFFSET: - cmdStopSound(obj, 0); + PUT_SEL32V(_segMan, obj, signal, SIGNAL_OFFSET); break; default: // Sync the signal of the sound object @@ -885,7 +885,11 @@ void SoundCommandParser::cmdSetSoundVolume(reg_t obj, int16 value) { #ifndef USE_OLD_MUSIC_FUNCTIONS MusicEntry *musicSlot = _music->getSlot(obj); if (!musicSlot) { - warning("cmdSetSoundVolume: Slot not found (%04x:%04x)", PRINT_REG(obj)); + // Do not throw a warning if the sound can't be found, as in some games + // this is called before the actual sound is loaded (e.g. SQ4CD, with the + // drum sounds of the energizer bunny at the beginning), so this is normal + // behavior + //warning("cmdSetSoundVolume: Slot not found (%04x:%04x)", PRINT_REG(obj)); return; } -- cgit v1.2.3