diff options
author | Max Horn | 2007-07-22 09:17:23 +0000 |
---|---|---|
committer | Max Horn | 2007-07-22 09:17:23 +0000 |
commit | 425e6e278b323f95af5b223d06bec74f0db8d047 (patch) | |
tree | b427fa627f8ea635fd0108723bf4f86cfbcbdbe8 /engines/scumm/imuse_digi | |
parent | cfb4b08efcb0c608eca19fccda15f8e24a1cb2f0 (diff) | |
download | scummvm-rg350-425e6e278b323f95af5b223d06bec74f0db8d047.tar.gz scummvm-rg350-425e6e278b323f95af5b223d06bec74f0db8d047.tar.bz2 scummvm-rg350-425e6e278b323f95af5b223d06bec74f0db8d047.zip |
cleanup (in particular, don't call something 'soundHandle' which is not a Mixer::SoundHandle)
svn-id: r28162
Diffstat (limited to 'engines/scumm/imuse_digi')
-rw-r--r-- | engines/scumm/imuse_digi/dimuse.cpp | 46 | ||||
-rw-r--r-- | engines/scumm/imuse_digi/dimuse.h | 2 | ||||
-rw-r--r-- | engines/scumm/imuse_digi/dimuse_script.cpp | 10 | ||||
-rw-r--r-- | engines/scumm/imuse_digi/dimuse_sndmgr.cpp | 244 | ||||
-rw-r--r-- | engines/scumm/imuse_digi/dimuse_sndmgr.h | 70 | ||||
-rw-r--r-- | engines/scumm/imuse_digi/dimuse_track.cpp | 31 |
6 files changed, 204 insertions, 199 deletions
diff --git a/engines/scumm/imuse_digi/dimuse.cpp b/engines/scumm/imuse_digi/dimuse.cpp index 38e918c21a..6d2e7dd217 100644 --- a/engines/scumm/imuse_digi/dimuse.cpp +++ b/engines/scumm/imuse_digi/dimuse.cpp @@ -166,10 +166,10 @@ void IMuseDigital::saveOrLoad(Serializer *ser) { continue; } - track->soundHandle = _sound->openSound(track->soundId, + track->soundDesc = _sound->openSound(track->soundId, track->soundName, track->soundType, track->volGroupId, -1); - if (!track->soundHandle) { + if (!track->soundDesc) { warning("IMuseDigital::saveOrLoad: Can't open sound so will not be resumed, propably on diffrent CD"); track->streamSou = NULL; track->stream = NULL; @@ -180,14 +180,14 @@ void IMuseDigital::saveOrLoad(Serializer *ser) { if (track->sndDataExtComp) { track->regionOffset = 0; } - track->sndDataExtComp = _sound->isSndDataExtComp(track->soundHandle); + track->sndDataExtComp = _sound->isSndDataExtComp(track->soundDesc); if (track->sndDataExtComp) { track->regionOffset = 0; } - track->dataOffset = _sound->getRegionOffset(track->soundHandle, track->curRegion); - int bits = _sound->getBits(track->soundHandle); - int channels = _sound->getChannels(track->soundHandle); - int freq = _sound->getFreq(track->soundHandle); + track->dataOffset = _sound->getRegionOffset(track->soundDesc, track->curRegion); + int bits = _sound->getBits(track->soundDesc); + int channels = _sound->getChannels(track->soundDesc); + int freq = _sound->getFreq(track->soundDesc); track->feedSize = freq * channels; track->mixerFlags = 0; if (channels == 2) @@ -285,8 +285,8 @@ void IMuseDigital::callback() { continue; } - int bits = _sound->getBits(track->soundHandle); - int channels = _sound->getChannels(track->soundHandle); + int bits = _sound->getBits(track->soundDesc); + int channels = _sound->getChannels(track->soundDesc); int32 feedSize = track->feedSize / _callbackFps; @@ -317,12 +317,12 @@ void IMuseDigital::callback() { track->dataMod12Bit = feedSize - tmpLength12Bits; int32 tmpOffset = (track->regionOffset * 3) / 4; - int tmpFeedSize = _sound->getDataFromRegion(track->soundHandle, track->curRegion, &tmpPtr, tmpOffset, tmpFeedSize12Bits); + int tmpFeedSize = _sound->getDataFromRegion(track->soundDesc, track->curRegion, &tmpPtr, tmpOffset, tmpFeedSize12Bits); curFeedSize = BundleCodecs::decode12BitsSample(tmpPtr, &tmpSndBufferPtr, tmpFeedSize); free(tmpPtr); } else if (bits == 16) { - curFeedSize = _sound->getDataFromRegion(track->soundHandle, track->curRegion, &tmpSndBufferPtr, track->regionOffset, feedSize); + curFeedSize = _sound->getDataFromRegion(track->soundDesc, track->curRegion, &tmpSndBufferPtr, track->regionOffset, feedSize); if (channels == 1) { curFeedSize &= ~1; } @@ -330,7 +330,7 @@ void IMuseDigital::callback() { curFeedSize &= ~3; } } else if (bits == 8) { - curFeedSize = _sound->getDataFromRegion(track->soundHandle, track->curRegion, &tmpSndBufferPtr, track->regionOffset, feedSize); + curFeedSize = _sound->getDataFromRegion(track->soundDesc, track->curRegion, &tmpSndBufferPtr, track->regionOffset, feedSize); if (channels == 2) { curFeedSize &= ~1; } @@ -347,7 +347,7 @@ void IMuseDigital::callback() { } else delete[] tmpSndBufferPtr; - if (_sound->isEndOfRegion(track->soundHandle, track->curRegion)) { + if (_sound->isEndOfRegion(track->soundDesc, track->curRegion)) { switchToNextRegion(track); if (track->toBeRemoved) break; @@ -380,7 +380,7 @@ void IMuseDigital::switchToNextRegion(Track *track) { return; } - int num_regions = _sound->getNumRegions(track->soundHandle); + int num_regions = _sound->getNumRegions(track->soundDesc); if (++track->curRegion == num_regions) { track->toBeRemoved = true; @@ -388,22 +388,22 @@ void IMuseDigital::switchToNextRegion(Track *track) { return; } - ImuseDigiSndMgr::soundStruct *soundHandle = track->soundHandle; - int jumpId = _sound->getJumpIdByRegionAndHookId(soundHandle, track->curRegion, track->curHookId); + ImuseDigiSndMgr::SoundDesc *soundDesc = track->soundDesc; + int jumpId = _sound->getJumpIdByRegionAndHookId(soundDesc, track->curRegion, track->curHookId); if (jumpId == -1) - jumpId = _sound->getJumpIdByRegionAndHookId(soundHandle, track->curRegion, 0); + jumpId = _sound->getJumpIdByRegionAndHookId(soundDesc, track->curRegion, 0); if (jumpId != -1) { - int region = _sound->getRegionIdByJumpId(soundHandle, jumpId); + int region = _sound->getRegionIdByJumpId(soundDesc, jumpId); assert(region != -1); - int sampleHookId = _sound->getJumpHookId(soundHandle, jumpId); + int sampleHookId = _sound->getJumpHookId(soundDesc, jumpId); assert(sampleHookId != -1); - int fadeDelay = (60 * _sound->getJumpFade(soundHandle, jumpId)) / 1000; + int fadeDelay = (60 * _sound->getJumpFade(soundDesc, jumpId)) / 1000; if (sampleHookId != 0) { if (track->curHookId == sampleHookId) { if (fadeDelay != 0) { Track *fadeTrack = cloneToFadeOutTrack(track, fadeDelay); if (fadeTrack) { - fadeTrack->dataOffset = _sound->getRegionOffset(fadeTrack->soundHandle, fadeTrack->curRegion); + fadeTrack->dataOffset = _sound->getRegionOffset(fadeTrack->soundDesc, fadeTrack->curRegion); fadeTrack->regionOffset = 0; debug(5, "switchToNextRegion-sound(%d) select region %d, curHookId: %d", fadeTrack->soundId, fadeTrack->curRegion, fadeTrack->curHookId); fadeTrack->curHookId = 0; @@ -417,7 +417,7 @@ void IMuseDigital::switchToNextRegion(Track *track) { if (fadeDelay != 0) { Track *fadeTrack = cloneToFadeOutTrack(track, fadeDelay); if (fadeTrack) { - fadeTrack->dataOffset = _sound->getRegionOffset(fadeTrack->soundHandle, fadeTrack->curRegion); + fadeTrack->dataOffset = _sound->getRegionOffset(fadeTrack->soundDesc, fadeTrack->curRegion); fadeTrack->regionOffset = 0; debug(5, "switchToNextRegion-sound(%d) select region %d, curHookId: %d", fadeTrack->soundId, fadeTrack->curRegion, fadeTrack->curHookId); } @@ -428,7 +428,7 @@ void IMuseDigital::switchToNextRegion(Track *track) { } debug(5, "switchToNextRegion-sound(%d) select region %d, curHookId: %d", track->soundId, track->curRegion, track->curHookId); - track->dataOffset = _sound->getRegionOffset(soundHandle, track->curRegion); + track->dataOffset = _sound->getRegionOffset(soundDesc, track->curRegion); track->regionOffset = 0; } diff --git a/engines/scumm/imuse_digi/dimuse.h b/engines/scumm/imuse_digi/dimuse.h index 1b088298df..dca9baac60 100644 --- a/engines/scumm/imuse_digi/dimuse.h +++ b/engines/scumm/imuse_digi/dimuse.h @@ -98,7 +98,7 @@ private: int32 dataMod12Bit; // value used between all callback to align 12 bit source of data int32 mixerFlags; // flags for sound mixer's channel (kFlagStereo, kFlag16Bits, kFlagReverseStereo, kFlagUnsigned, kFlagLittleEndian) - ImuseDigiSndMgr::soundStruct *soundHandle; // sound handle used by iMuse sound manager + ImuseDigiSndMgr::SoundDesc *soundDesc; // sound handle used by iMuse sound manager Audio::SoundHandle mixChanHandle; // sound mixer's channel handle Audio::AppendableAudioStream *stream; // sound mixer's audio stream handle for *.la1 and *.bun Audio::AudioStream *streamSou; // sound mixer's audio stream handle for *.sou diff --git a/engines/scumm/imuse_digi/dimuse_script.cpp b/engines/scumm/imuse_digi/dimuse_script.cpp index 186d04483e..ddc0cd5107 100644 --- a/engines/scumm/imuse_digi/dimuse_script.cpp +++ b/engines/scumm/imuse_digi/dimuse_script.cpp @@ -179,8 +179,8 @@ void IMuseDigital::flushTracks() { _mixer->stopHandle(track->mixChanHandle); delete track->stream; track->stream = NULL; - _sound->closeSound(track->soundHandle); - track->soundHandle = NULL; + _sound->closeSound(track->soundDesc); + track->soundDesc = NULL; track->used = false; } } else if (track->streamSou) { @@ -245,7 +245,7 @@ void IMuseDigital::getLipSync(int soundId, int syncId, int32 msPos, int32 &width for (int l = 0; l < MAX_DIGITAL_TRACKS; l++) { Track *track = _track[l]; if ((track->soundId == soundId) && track->used && !track->toBeRemoved) { - _sound->getSyncSizeAndPtrById(track->soundHandle, syncId, sync_size, &sync_ptr); + _sound->getSyncSizeAndPtrById(track->soundDesc, syncId, sync_size, &sync_ptr); if ((sync_size != 0) && (sync_ptr != NULL)) { sync_size /= 4; while (sync_size--) { @@ -396,8 +396,8 @@ void IMuseDigital::stopAllSounds() { _mixer->stopHandle(track->mixChanHandle); delete track->stream; track->stream = NULL; - _sound->closeSound(track->soundHandle); - track->soundHandle = NULL; + _sound->closeSound(track->soundDesc); + track->soundDesc = NULL; } else if (track->streamSou) { _mixer->stopHandle(track->mixChanHandle); delete track->streamSou; diff --git a/engines/scumm/imuse_digi/dimuse_sndmgr.cpp b/engines/scumm/imuse_digi/dimuse_sndmgr.cpp index 8340af3eb5..3f44873e46 100644 --- a/engines/scumm/imuse_digi/dimuse_sndmgr.cpp +++ b/engines/scumm/imuse_digi/dimuse_sndmgr.cpp @@ -40,7 +40,7 @@ namespace Scumm { ImuseDigiSndMgr::ImuseDigiSndMgr(ScummEngine *scumm) { for (int l = 0; l < MAX_IMUSE_SOUNDS; l++) { - memset(&_sounds[l], 0, sizeof(soundStruct)); + memset(&_sounds[l], 0, sizeof(SoundDesc)); } _vm = scumm; _disk = 0; @@ -88,7 +88,7 @@ void ImuseDigiSndMgr::countElements(byte *ptr, int &numRegions, int &numJumps, i } while (tag != MKID_BE('DATA')); } -void ImuseDigiSndMgr::prepareSoundFromRMAP(Common::File *file, soundStruct *sound, int32 offset, int32 size) { +void ImuseDigiSndMgr::prepareSoundFromRMAP(Common::File *file, SoundDesc *sound, int32 offset, int32 size) { int l; file->seek(offset, SEEK_SET); @@ -104,11 +104,11 @@ void ImuseDigiSndMgr::prepareSoundFromRMAP(Common::File *file, soundStruct *soun sound->numRegions = file->readUint32BE(); sound->numJumps = file->readUint32BE(); sound->numSyncs = file->readUint32BE(); - sound->region = (_region *)malloc(sizeof(_region) * sound->numRegions); + sound->region = new Region[sound->numRegions]; assert(sound->region); - sound->jump = (_jump *)malloc(sizeof(_jump) * sound->numJumps); + sound->jump = new Jump[sound->numJumps]; assert(sound->jump); - sound->sync = (_sync *)malloc(sizeof(_sync) * sound->numSyncs); + sound->sync = new Sync[sound->numSyncs]; assert(sound->sync); for (l = 0; l < sound->numRegions; l++) { sound->region[l].offset = file->readUint32BE(); @@ -127,7 +127,7 @@ void ImuseDigiSndMgr::prepareSoundFromRMAP(Common::File *file, soundStruct *soun } } -void ImuseDigiSndMgr::prepareSound(byte *ptr, soundStruct *sound) { +void ImuseDigiSndMgr::prepareSound(byte *ptr, SoundDesc *sound) { if (READ_BE_UINT32(ptr) == MKID_BE('Crea')) { bool quit = false; int len; @@ -135,10 +135,16 @@ void ImuseDigiSndMgr::prepareSound(byte *ptr, soundStruct *sound) { int32 offset = READ_LE_UINT16(ptr + 20); int16 code = READ_LE_UINT16(ptr + 24); - sound->region = (_region *)malloc(sizeof(_region) * 70); + sound->numRegions = 70; + sound->region = new Region[70]; assert(sound->region); - sound->jump = (_jump *)malloc(sizeof(_jump)); + + sound->numJumps = 1; + sound->jump = new Jump[1]; assert(sound->jump); + + sound->numSyncs = 0; + sound->resPtr = ptr; sound->bits = 8; sound->channels = 1; @@ -205,11 +211,11 @@ void ImuseDigiSndMgr::prepareSound(byte *ptr, soundStruct *sound) { sound->numJumps = 0; sound->numSyncs = 0; countElements(ptr, sound->numRegions, sound->numJumps, sound->numSyncs); - sound->region = (_region *)malloc(sizeof(_region) * sound->numRegions); + sound->region = new Region[sound->numRegions]; assert(sound->region); - sound->jump = (_jump *)malloc(sizeof(_jump) * sound->numJumps); + sound->jump = new Jump[sound->numJumps]; assert(sound->jump); - sound->sync = (_sync *)malloc(sizeof(_sync) * sound->numSyncs); + sound->sync = new Sync[sound->numSyncs]; assert(sound->sync); do { @@ -260,7 +266,7 @@ void ImuseDigiSndMgr::prepareSound(byte *ptr, soundStruct *sound) { } } -ImuseDigiSndMgr::soundStruct *ImuseDigiSndMgr::allocSlot() { +ImuseDigiSndMgr::SoundDesc *ImuseDigiSndMgr::allocSlot() { for (int l = 0; l < MAX_IMUSE_SOUNDS; l++) { if (!_sounds[l].inUse) { _sounds[l].inUse = true; @@ -271,7 +277,7 @@ ImuseDigiSndMgr::soundStruct *ImuseDigiSndMgr::allocSlot() { return NULL; } -bool ImuseDigiSndMgr::openMusicBundle(soundStruct *sound, int disk) { +bool ImuseDigiSndMgr::openMusicBundle(SoundDesc *sound, int disk) { bool result = false; sound->bundle = new BundleMgr(_cacheBundleDir); @@ -306,7 +312,7 @@ bool ImuseDigiSndMgr::openMusicBundle(soundStruct *sound, int disk) { return result; } -bool ImuseDigiSndMgr::openVoiceBundle(soundStruct *sound, int disk) { +bool ImuseDigiSndMgr::openVoiceBundle(SoundDesc *sound, int disk) { bool result = false; sound->bundle = new BundleMgr(_cacheBundleDir); @@ -341,11 +347,11 @@ bool ImuseDigiSndMgr::openVoiceBundle(soundStruct *sound, int disk) { return result; } -ImuseDigiSndMgr::soundStruct *ImuseDigiSndMgr::openSound(int32 soundId, const char *soundName, int soundType, int volGroupId, int disk) { +ImuseDigiSndMgr::SoundDesc *ImuseDigiSndMgr::openSound(int32 soundId, const char *soundName, int soundType, int volGroupId, int disk) { assert(soundId >= 0); assert(soundType); - soundStruct *sound = allocSlot(); + SoundDesc *sound = allocSlot(); if (!sound) { error("ImuseDigiSndMgr::openSound() can't alloc free sound slot"); } @@ -423,99 +429,97 @@ ImuseDigiSndMgr::soundStruct *ImuseDigiSndMgr::openSound(int32 soundId, const ch return sound; } -void ImuseDigiSndMgr::closeSound(soundStruct *soundHandle) { - assert(checkForProperHandle(soundHandle)); +void ImuseDigiSndMgr::closeSound(SoundDesc *soundDesc) { + assert(checkForProperHandle(soundDesc)); - if (soundHandle->resPtr) { + if (soundDesc->resPtr) { bool found = false; for (int l = 0; l < MAX_IMUSE_SOUNDS; l++) { - if ((_sounds[l].soundId == soundHandle->soundId) && (&_sounds[l] != soundHandle)) + if ((_sounds[l].soundId == soundDesc->soundId) && (&_sounds[l] != soundDesc)) found = true; } if (!found) - _vm->_res->unlock(rtSound, soundHandle->soundId); + _vm->_res->unlock(rtSound, soundDesc->soundId); } - if (soundHandle->compressedStream) - delete soundHandle->compressedStream; - - delete soundHandle->bundle; + delete soundDesc->compressedStream; + delete soundDesc->bundle; - for (int r = 0; r < soundHandle->numSyncs; r++) - free(soundHandle->sync[r].ptr); - free(soundHandle->region); - free(soundHandle->jump); - free(soundHandle->sync); - memset(soundHandle, 0, sizeof(soundStruct)); + for (int r = 0; r < soundDesc->numSyncs; r++) + free(soundDesc->sync[r].ptr); + delete[] soundDesc->region; + delete[] soundDesc->jump; + delete[] soundDesc->sync; + memset(soundDesc, 0, sizeof(SoundDesc)); } -ImuseDigiSndMgr::soundStruct *ImuseDigiSndMgr::cloneSound(soundStruct *soundHandle) { - assert(checkForProperHandle(soundHandle)); +ImuseDigiSndMgr::SoundDesc *ImuseDigiSndMgr::cloneSound(SoundDesc *soundDesc) { + assert(checkForProperHandle(soundDesc)); - return openSound(soundHandle->soundId, soundHandle->name, soundHandle->type, soundHandle->volGroupId, soundHandle->disk); + return openSound(soundDesc->soundId, soundDesc->name, soundDesc->type, soundDesc->volGroupId, soundDesc->disk); } -bool ImuseDigiSndMgr::checkForProperHandle(soundStruct *soundHandle) { - if (!soundHandle) +bool ImuseDigiSndMgr::checkForProperHandle(SoundDesc *soundDesc) { + if (!soundDesc) return false; for (int l = 0; l < MAX_IMUSE_SOUNDS; l++) { - if (soundHandle == &_sounds[l]) + if (soundDesc == &_sounds[l]) return true; } return false; } -bool ImuseDigiSndMgr::isSndDataExtComp(soundStruct *soundHandle) { - assert(checkForProperHandle(soundHandle)); - return soundHandle->compressed; +bool ImuseDigiSndMgr::isSndDataExtComp(SoundDesc *soundDesc) { + assert(checkForProperHandle(soundDesc)); + return soundDesc->compressed; } -int ImuseDigiSndMgr::getFreq(soundStruct *soundHandle) { - assert(checkForProperHandle(soundHandle)); - return soundHandle->freq; +int ImuseDigiSndMgr::getFreq(SoundDesc *soundDesc) { + assert(checkForProperHandle(soundDesc)); + return soundDesc->freq; } -int ImuseDigiSndMgr::getBits(soundStruct *soundHandle) { - assert(checkForProperHandle(soundHandle)); - return soundHandle->bits; +int ImuseDigiSndMgr::getBits(SoundDesc *soundDesc) { + assert(checkForProperHandle(soundDesc)); + return soundDesc->bits; } -int ImuseDigiSndMgr::getChannels(soundStruct *soundHandle) { - assert(checkForProperHandle(soundHandle)); - return soundHandle->channels; +int ImuseDigiSndMgr::getChannels(SoundDesc *soundDesc) { + assert(checkForProperHandle(soundDesc)); + return soundDesc->channels; } -bool ImuseDigiSndMgr::isEndOfRegion(soundStruct *soundHandle, int region) { - assert(checkForProperHandle(soundHandle)); - assert(region >= 0 && region < soundHandle->numRegions); - return soundHandle->endFlag; +bool ImuseDigiSndMgr::isEndOfRegion(SoundDesc *soundDesc, int region) { + assert(checkForProperHandle(soundDesc)); + assert(region >= 0 && region < soundDesc->numRegions); + return soundDesc->endFlag; } -int ImuseDigiSndMgr::getNumRegions(soundStruct *soundHandle) { - assert(checkForProperHandle(soundHandle)); - return soundHandle->numRegions; +int ImuseDigiSndMgr::getNumRegions(SoundDesc *soundDesc) { + assert(checkForProperHandle(soundDesc)); + return soundDesc->numRegions; } -int ImuseDigiSndMgr::getNumJumps(soundStruct *soundHandle) { - assert(checkForProperHandle(soundHandle)); - return soundHandle->numJumps; +int ImuseDigiSndMgr::getNumJumps(SoundDesc *soundDesc) { + assert(checkForProperHandle(soundDesc)); + return soundDesc->numJumps; } -int ImuseDigiSndMgr::getRegionOffset(soundStruct *soundHandle, int region) { +int ImuseDigiSndMgr::getRegionOffset(SoundDesc *soundDesc, int region) { debug(5, "getRegionOffset() region:%d", region); - assert(checkForProperHandle(soundHandle)); - assert(region >= 0 && region < soundHandle->numRegions); - return soundHandle->region[region].offset; + assert(checkForProperHandle(soundDesc)); + assert(region >= 0 && region < soundDesc->numRegions); + return soundDesc->region[region].offset; } -int ImuseDigiSndMgr::getJumpIdByRegionAndHookId(soundStruct *soundHandle, int region, int hookId) { +int ImuseDigiSndMgr::getJumpIdByRegionAndHookId(SoundDesc *soundDesc, int region, int hookId) { debug(5, "getJumpIdByRegionAndHookId() region:%d, hookId:%d", region, hookId); - assert(checkForProperHandle(soundHandle)); - assert(region >= 0 && region < soundHandle->numRegions); - int32 offset = soundHandle->region[region].offset; - for (int l = 0; l < soundHandle->numJumps; l++) { - if (offset == soundHandle->jump[l].offset) { - if (soundHandle->jump[l].hookId == hookId) + assert(checkForProperHandle(soundDesc)); + assert(region >= 0 && region < soundDesc->numRegions); + int32 offset = soundDesc->region[region].offset; + for (int l = 0; l < soundDesc->numJumps; l++) { + if (offset == soundDesc->jump[l].offset) { + if (soundDesc->jump[l].hookId == hookId) return l; } } @@ -523,25 +527,25 @@ int ImuseDigiSndMgr::getJumpIdByRegionAndHookId(soundStruct *soundHandle, int re return -1; } -void ImuseDigiSndMgr::getSyncSizeAndPtrById(soundStruct *soundHandle, int number, int32 &sync_size, byte **sync_ptr) { - assert(checkForProperHandle(soundHandle)); +void ImuseDigiSndMgr::getSyncSizeAndPtrById(SoundDesc *soundDesc, int number, int32 &sync_size, byte **sync_ptr) { + assert(checkForProperHandle(soundDesc)); assert(number >= 0); - if (number < soundHandle->numSyncs) { - sync_size = soundHandle->sync[number].size; - *sync_ptr = soundHandle->sync[number].ptr; + if (number < soundDesc->numSyncs) { + sync_size = soundDesc->sync[number].size; + *sync_ptr = soundDesc->sync[number].ptr; } else { sync_size = 0; *sync_ptr = NULL; } } -int ImuseDigiSndMgr::getRegionIdByJumpId(soundStruct *soundHandle, int jumpId) { +int ImuseDigiSndMgr::getRegionIdByJumpId(SoundDesc *soundDesc, int jumpId) { debug(5, "getRegionIdByJumpId() jumpId:%d", jumpId); - assert(checkForProperHandle(soundHandle)); - assert(jumpId >= 0 && jumpId < soundHandle->numJumps); - int32 dest = soundHandle->jump[jumpId].dest; - for (int l = 0; l < soundHandle->numRegions; l++) { - if (dest == soundHandle->region[l].offset) { + assert(checkForProperHandle(soundDesc)); + assert(jumpId >= 0 && jumpId < soundDesc->numJumps); + int32 dest = soundDesc->jump[jumpId].dest; + for (int l = 0; l < soundDesc->numRegions; l++) { + if (dest == soundDesc->region[l].offset) { return l; } } @@ -549,64 +553,64 @@ int ImuseDigiSndMgr::getRegionIdByJumpId(soundStruct *soundHandle, int jumpId) { return -1; } -int ImuseDigiSndMgr::getJumpHookId(soundStruct *soundHandle, int number) { +int ImuseDigiSndMgr::getJumpHookId(SoundDesc *soundDesc, int number) { debug(5, "getJumpHookId() number:%d", number); - assert(checkForProperHandle(soundHandle)); - assert(number >= 0 && number < soundHandle->numJumps); - return soundHandle->jump[number].hookId; + assert(checkForProperHandle(soundDesc)); + assert(number >= 0 && number < soundDesc->numJumps); + return soundDesc->jump[number].hookId; } -int ImuseDigiSndMgr::getJumpFade(soundStruct *soundHandle, int number) { +int ImuseDigiSndMgr::getJumpFade(SoundDesc *soundDesc, int number) { debug(5, "getJumpFade() number:%d", number); - assert(checkForProperHandle(soundHandle)); - assert(number >= 0 && number < soundHandle->numJumps); - return soundHandle->jump[number].fadeDelay; + assert(checkForProperHandle(soundDesc)); + assert(number >= 0 && number < soundDesc->numJumps); + return soundDesc->jump[number].fadeDelay; } -int32 ImuseDigiSndMgr::getDataFromRegion(soundStruct *soundHandle, int region, byte **buf, int32 offset, int32 size) { - debug(5, "getDataFromRegion() region:%d, offset:%d, size:%d, numRegions:%d", region, offset, size, soundHandle->numRegions); - assert(checkForProperHandle(soundHandle)); +int32 ImuseDigiSndMgr::getDataFromRegion(SoundDesc *soundDesc, int region, byte **buf, int32 offset, int32 size) { + debug(5, "getDataFromRegion() region:%d, offset:%d, size:%d, numRegions:%d", region, offset, size, soundDesc->numRegions); + assert(checkForProperHandle(soundDesc)); assert(buf && offset >= 0 && size >= 0); - assert(region >= 0 && region < soundHandle->numRegions); + assert(region >= 0 && region < soundDesc->numRegions); - int32 region_offset = soundHandle->region[region].offset; - int32 region_length = soundHandle->region[region].length; - int32 offset_data = soundHandle->offsetData; + int32 region_offset = soundDesc->region[region].offset; + int32 region_length = soundDesc->region[region].length; + int32 offset_data = soundDesc->offsetData; int32 start = region_offset - offset_data; if (offset + size + offset_data > region_length) { size = region_length - offset; - soundHandle->endFlag = true; + soundDesc->endFlag = true; } else { - soundHandle->endFlag = false; + soundDesc->endFlag = false; } - int header_size = soundHandle->offsetData; + int header_size = soundDesc->offsetData; bool header_outside = ((_vm->_game.id == GID_CMI) && !(_vm->_game.features & GF_DEMO)); - if ((soundHandle->bundle) && (!soundHandle->compressed)) { - size = soundHandle->bundle->decompressSampleByCurIndex(start + offset, size, buf, header_size, header_outside); - } else if (soundHandle->resPtr) { + if ((soundDesc->bundle) && (!soundDesc->compressed)) { + size = soundDesc->bundle->decompressSampleByCurIndex(start + offset, size, buf, header_size, header_outside); + } else if (soundDesc->resPtr) { *buf = new byte[size]; assert(*buf); - memcpy(*buf, soundHandle->resPtr + start + offset + header_size, size); - } else if ((soundHandle->bundle) && (soundHandle->compressed)) { + memcpy(*buf, soundDesc->resPtr + start + offset + header_size, size); + } else if ((soundDesc->bundle) && (soundDesc->compressed)) { *buf = new byte[size]; assert(*buf); char fileName[24]; - sprintf(fileName, "%s_reg%03d", soundHandle->name, region); - if (scumm_stricmp(fileName, soundHandle->lastFileName) != 0) { + sprintf(fileName, "%s_reg%03d", soundDesc->name, region); + if (scumm_stricmp(fileName, soundDesc->lastFileName) != 0) { int32 offs = 0, len = 0; Common::File *cmpFile; bool oggMode = false; - sprintf(fileName, "%s_reg%03d.mp3", soundHandle->name, region); - cmpFile = soundHandle->bundle->getFile(fileName, offs, len); + sprintf(fileName, "%s_reg%03d.mp3", soundDesc->name, region); + cmpFile = soundDesc->bundle->getFile(fileName, offs, len); #ifndef USE_MAD if (len) error("Mad library compiled support needed!"); #endif if (!len) { - sprintf(fileName, "%s_reg%03d.ogg", soundHandle->name, region); - cmpFile = soundHandle->bundle->getFile(fileName, offs, len); + sprintf(fileName, "%s_reg%03d.ogg", soundDesc->name, region); + cmpFile = soundDesc->bundle->getFile(fileName, offs, len); #ifndef USE_VORBIS if (len) error("Vorbis library compiled support needed!"); @@ -614,26 +618,26 @@ int32 ImuseDigiSndMgr::getDataFromRegion(soundStruct *soundHandle, int region, b assert(len); oggMode = true; } - if (!soundHandle->compressedStream) { + if (!soundDesc->compressedStream) { Common::MemoryReadStream *tmp = cmpFile->readStream(len); assert(tmp); #ifdef USE_VORBIS if (oggMode) - soundHandle->compressedStream = Audio::makeVorbisStream(tmp, true); + soundDesc->compressedStream = Audio::makeVorbisStream(tmp, true); #endif #ifdef USE_MAD if (!oggMode) - soundHandle->compressedStream = Audio::makeMP3Stream(tmp, true); + soundDesc->compressedStream = Audio::makeMP3Stream(tmp, true); #endif - assert(soundHandle->compressedStream); + assert(soundDesc->compressedStream); } - strcpy(soundHandle->lastFileName, fileName); + strcpy(soundDesc->lastFileName, fileName); } - size = soundHandle->compressedStream->readBuffer((int16 *)*buf, size / 2) * 2; - if (soundHandle->compressedStream->endOfData()) { - delete soundHandle->compressedStream; - soundHandle->compressedStream = NULL; - soundHandle->lastFileName[0] = 0; + size = soundDesc->compressedStream->readBuffer((int16 *)*buf, size / 2) * 2; + if (soundDesc->compressedStream->endOfData()) { + delete soundDesc->compressedStream; + soundDesc->compressedStream = NULL; + soundDesc->lastFileName[0] = 0; } } diff --git a/engines/scumm/imuse_digi/dimuse_sndmgr.h b/engines/scumm/imuse_digi/dimuse_sndmgr.h index 5d2f8c88ba..e4e2e795a2 100644 --- a/engines/scumm/imuse_digi/dimuse_sndmgr.h +++ b/engines/scumm/imuse_digi/dimuse_sndmgr.h @@ -48,35 +48,39 @@ public: #define IMUSE_VOLGRP_MUSIC 3 private: - struct _region { + struct Region { int32 offset; // offset of region int32 length; // lenght of region }; - struct _jump { + struct Jump { int32 offset; // jump offset position int32 dest; // jump to dest position byte hookId; // id of hook int16 fadeDelay; // fade delay in ms }; - struct _sync { + struct Sync { int32 size; // size of sync byte *ptr; // pointer to sync }; public: - struct soundStruct { + struct SoundDesc { uint16 freq; // frequency byte channels; // stereo or mono byte bits; // 8, 12, 16 + int numJumps; // number of Jumps + Region *region; + int numRegions; // number of Regions + Jump *jump; + int numSyncs; // number of Syncs - _region *region; - _jump *jump; - _sync *sync; + Sync *sync; + bool endFlag; bool inUse; byte *allData; @@ -95,19 +99,19 @@ public: private: - soundStruct _sounds[MAX_IMUSE_SOUNDS]; + SoundDesc _sounds[MAX_IMUSE_SOUNDS]; - bool checkForProperHandle(soundStruct *soundHandle); - soundStruct *allocSlot(); - void prepareSound(byte *ptr, soundStruct *sound); - void prepareSoundFromRMAP(Common::File *file, soundStruct *sound, int32 offset, int32 size); + bool checkForProperHandle(SoundDesc *soundDesc); + SoundDesc *allocSlot(); + void prepareSound(byte *ptr, SoundDesc *sound); + void prepareSoundFromRMAP(Common::File *file, SoundDesc *sound, int32 offset, int32 size); ScummEngine *_vm; byte _disk; BundleDirCache *_cacheBundleDir; - bool openMusicBundle(soundStruct *sound, int disk); - bool openVoiceBundle(soundStruct *sound, int disk); + bool openMusicBundle(SoundDesc *sound, int disk); + bool openVoiceBundle(SoundDesc *sound, int disk); void countElements(byte *ptr, int &numRegions, int &numJumps, int &numSyncs); @@ -116,25 +120,25 @@ public: ImuseDigiSndMgr(ScummEngine *scumm); ~ImuseDigiSndMgr(); - soundStruct *openSound(int32 soundId, const char *soundName, int soundType, int volGroupId, int disk); - void closeSound(soundStruct *soundHandle); - soundStruct *cloneSound(soundStruct *soundHandle); - - bool isSndDataExtComp(soundStruct *soundHandle); - int getFreq(soundStruct *soundHandle); - int getBits(soundStruct *soundHandle); - int getChannels(soundStruct *soundHandle); - bool isEndOfRegion(soundStruct *soundHandle, int region); - int getNumRegions(soundStruct *soundHandle); - int getNumJumps(soundStruct *soundHandle); - int getRegionOffset(soundStruct *soundHandle, int region); - int getJumpIdByRegionAndHookId(soundStruct *soundHandle, int region, int hookId); - int getRegionIdByJumpId(soundStruct *soundHandle, int jumpId); - int getJumpHookId(soundStruct *soundHandle, int number); - int getJumpFade(soundStruct *soundHandle, int number); - void getSyncSizeAndPtrById(soundStruct *soundHandle, int number, int32 &sync_size, byte **sync_ptr); - - int32 getDataFromRegion(soundStruct *soundHandle, int region, byte **buf, int32 offset, int32 size); + SoundDesc *openSound(int32 soundId, const char *soundName, int soundType, int volGroupId, int disk); + void closeSound(SoundDesc *soundDesc); + SoundDesc *cloneSound(SoundDesc *soundDesc); + + bool isSndDataExtComp(SoundDesc *soundDesc); + int getFreq(SoundDesc *soundDesc); + int getBits(SoundDesc *soundDesc); + int getChannels(SoundDesc *soundDesc); + bool isEndOfRegion(SoundDesc *soundDesc, int region); + int getNumRegions(SoundDesc *soundDesc); + int getNumJumps(SoundDesc *soundDesc); + int getRegionOffset(SoundDesc *soundDesc, int region); + int getJumpIdByRegionAndHookId(SoundDesc *soundDesc, int region, int hookId); + int getRegionIdByJumpId(SoundDesc *soundDesc, int jumpId); + int getJumpHookId(SoundDesc *soundDesc, int number); + int getJumpFade(SoundDesc *soundDesc, int number); + void getSyncSizeAndPtrById(SoundDesc *soundDesc, int number, int32 &sync_size, byte **sync_ptr); + + int32 getDataFromRegion(SoundDesc *soundDesc, int region, byte **buf, int32 offset, int32 size); }; } // End of namespace Scumm diff --git a/engines/scumm/imuse_digi/dimuse_track.cpp b/engines/scumm/imuse_digi/dimuse_track.cpp index 75dde5e60f..987e1bc3c9 100644 --- a/engines/scumm/imuse_digi/dimuse_track.cpp +++ b/engines/scumm/imuse_digi/dimuse_track.cpp @@ -117,20 +117,20 @@ void IMuseDigital::startSound(int soundId, const char *soundName, int soundType, track->feedSize = 0; track->souStreamUsed = true; track->soundName[0] = 0; - track->soundHandle = NULL; + track->soundDesc = NULL; } else { track->souStreamUsed = false; strcpy(track->soundName, soundName); - track->soundHandle = _sound->openSound(soundId, soundName, soundType, volGroupId, -1); + track->soundDesc = _sound->openSound(soundId, soundName, soundType, volGroupId, -1); - if (track->soundHandle == NULL) + if (track->soundDesc == NULL) return; - track->sndDataExtComp = _sound->isSndDataExtComp(track->soundHandle); + track->sndDataExtComp = _sound->isSndDataExtComp(track->soundDesc); - bits = _sound->getBits(track->soundHandle); - channels = _sound->getChannels(track->soundHandle); - freq = _sound->getFreq(track->soundHandle); + bits = _sound->getBits(track->soundDesc); + channels = _sound->getChannels(track->soundDesc); + freq = _sound->getFreq(track->soundDesc); if ((soundId == kTalkSoundID) && (soundType == IMUSE_BUNDLE)) { if (_vm->_actorToPrintStrFor != 0xFF && _vm->_actorToPrintStrFor != 0) { @@ -325,15 +325,12 @@ IMuseDigital::Track *IMuseDigital::cloneToFadeOutTrack(const Track *track, int f // Clone the settings of the given track memcpy(fadeTrack, track, sizeof(Track)); - // Clone the soundhandle - // FIXME: Shouldn't we check here whether track->soundHandle is NULL, resp. whether stream2 - // is being used (as in, we are using compressed data)... - // - // -- aquadran -- nope :) this is called only for bundle files and sound data in *.la1 - // from switchToNextRegion and fadeOutMusic func. - // stream2 is used only for sou VOICE type sound data (FT) -- - fadeTrack->soundHandle = _sound->cloneSound(track->soundHandle); - assert(fadeTrack->soundHandle); + // Clone the sound. + // According to aquadran, this is only called for bundle files and sound + // data in *.la1 from switchToNextRegion and fadeOutMusic func. Henc we + // know that track->soundDesc != NULL. + fadeTrack->soundDesc = _sound->cloneSound(track->soundDesc); + assert(fadeTrack->soundDesc); // Set the volume fading parameters to indicate a fade out fadeTrack->volFadeDelay = fadeDelay; @@ -357,7 +354,7 @@ IMuseDigital::Track *IMuseDigital::cloneToFadeOutTrack(const Track *track, int f type = Audio::Mixer::kPlainSoundType; break; } - fadeTrack->stream = Audio::makeAppendableAudioStream(_sound->getFreq(fadeTrack->soundHandle), makeMixerFlags(fadeTrack->mixerFlags)); + fadeTrack->stream = Audio::makeAppendableAudioStream(_sound->getFreq(fadeTrack->soundDesc), makeMixerFlags(fadeTrack->mixerFlags)); _mixer->playInputStream(type, &fadeTrack->mixChanHandle, fadeTrack->stream, -1, fadeTrack->vol / 1000, fadeTrack->pan, false); fadeTrack->mixerStreamRunning = true; |