[Scummvm-cvs-logs] SF.net SVN: scummvm: [28162] scummvm/trunk/engines/scumm/imuse_digi

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Sun Jul 22 11:17:23 CEST 2007


Revision: 28162
          http://scummvm.svn.sourceforge.net/scummvm/?rev=28162&view=rev
Author:   fingolfin
Date:     2007-07-22 02:17:23 -0700 (Sun, 22 Jul 2007)

Log Message:
-----------
cleanup (in particular, don't call something 'soundHandle' which is not a Mixer::SoundHandle)

Modified Paths:
--------------
    scummvm/trunk/engines/scumm/imuse_digi/dimuse.cpp
    scummvm/trunk/engines/scumm/imuse_digi/dimuse.h
    scummvm/trunk/engines/scumm/imuse_digi/dimuse_script.cpp
    scummvm/trunk/engines/scumm/imuse_digi/dimuse_sndmgr.cpp
    scummvm/trunk/engines/scumm/imuse_digi/dimuse_sndmgr.h
    scummvm/trunk/engines/scumm/imuse_digi/dimuse_track.cpp

Modified: scummvm/trunk/engines/scumm/imuse_digi/dimuse.cpp
===================================================================
--- scummvm/trunk/engines/scumm/imuse_digi/dimuse.cpp	2007-07-22 09:14:09 UTC (rev 28161)
+++ scummvm/trunk/engines/scumm/imuse_digi/dimuse.cpp	2007-07-22 09:17:23 UTC (rev 28162)
@@ -166,10 +166,10 @@
 				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 @@
 			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 @@
 						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 @@
 						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 @@
 							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 @@
 					} 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 @@
 		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 @@
 		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 @@
 			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 @@
 	}
 
 	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;
 }
 

Modified: scummvm/trunk/engines/scumm/imuse_digi/dimuse.h
===================================================================
--- scummvm/trunk/engines/scumm/imuse_digi/dimuse.h	2007-07-22 09:14:09 UTC (rev 28161)
+++ scummvm/trunk/engines/scumm/imuse_digi/dimuse.h	2007-07-22 09:17:23 UTC (rev 28162)
@@ -98,7 +98,7 @@
 		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

Modified: scummvm/trunk/engines/scumm/imuse_digi/dimuse_script.cpp
===================================================================
--- scummvm/trunk/engines/scumm/imuse_digi/dimuse_script.cpp	2007-07-22 09:14:09 UTC (rev 28161)
+++ scummvm/trunk/engines/scumm/imuse_digi/dimuse_script.cpp	2007-07-22 09:17:23 UTC (rev 28162)
@@ -179,8 +179,8 @@
 					_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 @@
 		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 @@
 				_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;

Modified: scummvm/trunk/engines/scumm/imuse_digi/dimuse_sndmgr.cpp
===================================================================
--- scummvm/trunk/engines/scumm/imuse_digi/dimuse_sndmgr.cpp	2007-07-22 09:14:09 UTC (rev 28161)
+++ scummvm/trunk/engines/scumm/imuse_digi/dimuse_sndmgr.cpp	2007-07-22 09:17:23 UTC (rev 28162)
@@ -40,7 +40,7 @@
 
 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 @@
 	} 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 @@
 	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::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 @@
 		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 @@
 		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 @@
 	}
 }
 
-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 @@
 	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 @@
 	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 @@
 	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 @@
 	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 soundDesc->compressedStream;
+	delete soundDesc->bundle;
 
-	delete soundHandle->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 @@
 	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 @@
 	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 @@
 				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;
 		}
 	}
 

Modified: scummvm/trunk/engines/scumm/imuse_digi/dimuse_sndmgr.h
===================================================================
--- scummvm/trunk/engines/scumm/imuse_digi/dimuse_sndmgr.h	2007-07-22 09:14:09 UTC (rev 28161)
+++ scummvm/trunk/engines/scumm/imuse_digi/dimuse_sndmgr.h	2007-07-22 09:17:23 UTC (rev 28162)
@@ -48,35 +48,39 @@
 #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 @@
 
 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 @@
 	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);
+	SoundDesc *openSound(int32 soundId, const char *soundName, int soundType, int volGroupId, int disk);
+	void closeSound(SoundDesc *soundDesc);
+	SoundDesc *cloneSound(SoundDesc *soundDesc);
 
-	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);
+	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(soundStruct *soundHandle, int region, byte **buf, int32 offset, int32 size);
+	int32 getDataFromRegion(SoundDesc *soundDesc, int region, byte **buf, int32 offset, int32 size);
 };
 
 } // End of namespace Scumm

Modified: scummvm/trunk/engines/scumm/imuse_digi/dimuse_track.cpp
===================================================================
--- scummvm/trunk/engines/scumm/imuse_digi/dimuse_track.cpp	2007-07-22 09:14:09 UTC (rev 28161)
+++ scummvm/trunk/engines/scumm/imuse_digi/dimuse_track.cpp	2007-07-22 09:17:23 UTC (rev 28162)
@@ -117,20 +117,20 @@
 		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 @@
 	// 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 @@
 		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;


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list