diff options
author | Paweł Kołodziejski | 2004-01-10 07:07:19 +0000 |
---|---|---|
committer | Paweł Kołodziejski | 2004-01-10 07:07:19 +0000 |
commit | 4654bab07625aa33d05745263dbf5a69dec3c160 (patch) | |
tree | 8c59933d2b714987783899ac02805b36085d10c1 /scumm | |
parent | 1778b01d765b8290c47324d6befebb9130353973 (diff) | |
download | scummvm-rg350-4654bab07625aa33d05745263dbf5a69dec3c160.tar.gz scummvm-rg350-4654bab07625aa33d05745263dbf5a69dec3c160.tar.bz2 scummvm-rg350-4654bab07625aa33d05745263dbf5a69dec3c160.zip |
removed stackLock and added locking tracks to prevent removed
svn-id: r12290
Diffstat (limited to 'scumm')
-rw-r--r-- | scumm/imuse_digi/dimuse.cpp | 23 | ||||
-rw-r--r-- | scumm/imuse_digi/dimuse.h | 1 | ||||
-rw-r--r-- | scumm/imuse_digi/dimuse_sndmgr.cpp | 19 | ||||
-rw-r--r-- | scumm/imuse_digi/dimuse_sndmgr.h | 1 |
4 files changed, 23 insertions, 21 deletions
diff --git a/scumm/imuse_digi/dimuse.cpp b/scumm/imuse_digi/dimuse.cpp index 5a131b016c..459a225877 100644 --- a/scumm/imuse_digi/dimuse.cpp +++ b/scumm/imuse_digi/dimuse.cpp @@ -72,7 +72,7 @@ void IMuseDigital::callback() { continue; } } else if (_track[l].stream) { - if (_track[l].toBeRemoved) { + if ((!_track[l].locked) && (_track[l].toBeRemoved)) { debug(5, "IMuseDigital::callback(): stoped sound: %d", _track[l].idSound); if (_track[l].stream) _track[l].stream->finish(); @@ -289,6 +289,7 @@ void IMuseDigital::startSound(int soundId, const char *soundName, int soundType, _curMusicId = soundId; } + _track[l].locked = false; _track[l].used = true; return; } @@ -299,11 +300,13 @@ void IMuseDigital::startSound(int soundId, const char *soundName, int soundType, void IMuseDigital::stopMusic() { debug(5, "IMuseDigital::stopMusic()"); for (int l = 0; l < MAX_DIGITAL_TRACKS; l++) { + _track[l].locked = true; if ((_track[l].idSound == _curMusicId) && _track[l].used) { if (_track[l].stream) { _track[l].toBeRemoved = true; } } + _track[l].locked = false; } _curMusicId = -1; } @@ -311,6 +314,7 @@ void IMuseDigital::stopMusic() { void IMuseDigital::stopSound(int soundId) { debug(5, "IMuseDigital::stopSound(%d)", soundId); for (int l = 0; l < MAX_DIGITAL_TRACKS; l++) { + _track[l].locked = true; if ((_track[l].idSound == soundId) && _track[l].used) { if (_track[l].stream) { _track[l].toBeRemoved = true; @@ -318,18 +322,21 @@ void IMuseDigital::stopSound(int soundId) { else if (_track[l].stream2) _vm->_mixer->stopHandle(_track[l].handle); } + _track[l].locked = false; } } void IMuseDigital::stopAllSounds(bool waitForStop) { debug(5, "IMuseDigital::stopAllSounds"); for (int l = 0; l < MAX_DIGITAL_TRACKS; l++) { + _track[l].locked = true; if (_track[l].used) { if (_track[l].stream) { _track[l].toBeRemoved = true; } else if (_track[l].stream2) _vm->_mixer->stopHandle(_track[l].handle); } + _track[l].locked = false; } _curMusicId = -1; @@ -347,9 +354,11 @@ void IMuseDigital::stopAllSounds(bool waitForStop) { void IMuseDigital::pause(bool p) { for (int l = 0; l < MAX_DIGITAL_TRACKS; l++) { + _track[l].locked = true; if (_track[l].used) { _vm->_mixer->pauseHandle(_track[l].handle, p); } + _track[l].locked = false; } _pause = p; } @@ -376,11 +385,13 @@ void IMuseDigital::parseScriptCmds(int a, int b, int c, int d, int e, int f, int case 0x600: // set volume debug(5, "ImuseSetParam (0x600), sample(%d), volume(%d)", sample, d); for (l = 0; l < MAX_DIGITAL_TRACKS; l++) { + _track[l].locked = true; if ((_track[l].idSound == sample) && _track[l].used) { _track[l].vol = d * 1000; // if (_track[l].volFadeUsed) // _track[l].volFadeStep = (_track[l].volFadeDest - _track[l].vol) * 60 * 40 / (1000 * _track[chan].volFadeDelay); } + _track[l].locked = false; } if (l == -1) { debug(5, "ImuseSetParam (0x600), sample(%d) not exist in channels", sample); @@ -390,9 +401,11 @@ void IMuseDigital::parseScriptCmds(int a, int b, int c, int d, int e, int f, int case 0x700: // set pan debug(5, "ImuseSetParam (0x700), sample(%d), pan(%d)", sample, d); for (l = 0; l < MAX_DIGITAL_TRACKS; l++) { + _track[l].locked = true; if ((_track[l].idSound == sample) && _track[l].used) { _track[l].pan = d; } + _track[l].locked = false; } if (l == -1) { debug(5, "ImuseSetParam (0x700), sample(%d) not exist in channels", sample); @@ -413,6 +426,7 @@ void IMuseDigital::parseScriptCmds(int a, int b, int c, int d, int e, int f, int return; } for (l = 0; l < MAX_DIGITAL_TRACKS; l++) { + _track[l].locked = true; if ((_track[l].idSound == sample) && _track[l].used) { _track[l].volFadeDelay = e; _track[l].volFadeDest = d * 1000; @@ -420,6 +434,7 @@ void IMuseDigital::parseScriptCmds(int a, int b, int c, int d, int e, int f, int _track[l].volFadeUsed = true; debug(5, "ImuseFadeParam: vol %d, volDest %d, step %d", _track[l].vol, d * 1000, _track[l].volFadeStep); } + _track[l].locked = false; } if (chan == -1) { debug(5, "ImuseFadeParam (0x600), sample %d not exist in channels", sample); @@ -583,6 +598,7 @@ void IMuseDigital::getLipSync(int soundId, int syncId, int32 msPos, int32 &width msPos /= 16; if (msPos < 65536) { for (int l = 0; l < MAX_DIGITAL_TRACKS; l++) { + _track[l].locked = true; if ((_track[l].idSound == soundId) && _track[l].used) { _sound->getSyncSizeAndPtrById(_track[l].soundHandle, syncId, sync_size, &sync_ptr); if ((sync_size != 0) && (sync_ptr != NULL)) { @@ -600,19 +616,24 @@ void IMuseDigital::getLipSync(int soundId, int syncId, int32 msPos, int32 &width width = sync_ptr[2]; height = sync_ptr[3]; + _track[l].locked = false; return; } } + _track[l].locked = false; } } } int32 IMuseDigital::getPosInMs(int soundId) { for (int l = 0; l < MAX_DIGITAL_TRACKS; l++) { + _track[l].locked = true; if ((_track[l].idSound == soundId) && _track[l].used) { int32 pos = 1000 * _track[l].trackOffset / _track[l].iteration; + _track[l].locked = false; return pos; } + _track[l].locked = false; } return 0; diff --git a/scumm/imuse_digi/dimuse.h b/scumm/imuse_digi/dimuse.h index 918bab6e03..c38f25b12a 100644 --- a/scumm/imuse_digi/dimuse.h +++ b/scumm/imuse_digi/dimuse.h @@ -57,6 +57,7 @@ private: int soundGroup; int iteration; int mod; + bool locked; int32 pullSize; ImuseDigiSndMgr::soundStruct *soundHandle; PlayingSoundHandle handle; diff --git a/scumm/imuse_digi/dimuse_sndmgr.cpp b/scumm/imuse_digi/dimuse_sndmgr.cpp index d10c04f100..7704106c7f 100644 --- a/scumm/imuse_digi/dimuse_sndmgr.cpp +++ b/scumm/imuse_digi/dimuse_sndmgr.cpp @@ -31,7 +31,6 @@ namespace Scumm { ImuseDigiSndMgr::ImuseDigiSndMgr(ScummEngine *scumm) { memset(&_sounds, 0, sizeof(_sounds)); _vm = scumm; - _mutex = g_system->create_mutex(); _disk = 0; _cacheBundleDir = new BundleDirCache(); BundleCodecs::initializeImcTables(); @@ -42,8 +41,6 @@ ImuseDigiSndMgr::~ImuseDigiSndMgr() { if (&_sounds[l]) closeSound(&_sounds[l]); } - delete _cacheBundleDir; - g_system->delete_mutex(_mutex); #ifdef __PALM_OS__ BundleCodecs::releaseImcTables(); #endif @@ -209,7 +206,6 @@ bool ImuseDigiSndMgr::openVoiceBundle(int slot) { ImuseDigiSndMgr::soundStruct *ImuseDigiSndMgr::openSound(int32 soundId, const char *soundName, int soundType, int soundGroup) { assert(soundId >= 0); assert(soundType); - Common::StackLock tmpLock(_mutex); int slot = allocSlot(); if (slot == -1) { @@ -273,7 +269,6 @@ ImuseDigiSndMgr::soundStruct *ImuseDigiSndMgr::openSound(int32 soundId, const ch void ImuseDigiSndMgr::closeSound(soundStruct *soundHandle) { assert(soundHandle && checkForProperHandle(soundHandle)); - Common::StackLock tmpLock(_mutex); for (int l = 0; l < MAX_IMUSE_SOUNDS; l++) { if (&_sounds[l] == soundHandle) { @@ -297,50 +292,42 @@ bool ImuseDigiSndMgr::checkForProperHandle(soundStruct *soundHandle) { } int ImuseDigiSndMgr::getFreq(soundStruct *soundHandle) { - Common::StackLock tmpLock(_mutex); assert(soundHandle && checkForProperHandle(soundHandle)); return soundHandle->freq; } int ImuseDigiSndMgr::getBits(soundStruct *soundHandle) { - Common::StackLock tmpLock(_mutex); assert(soundHandle && checkForProperHandle(soundHandle)); return soundHandle->bits; } int ImuseDigiSndMgr::getChannels(soundStruct *soundHandle) { - Common::StackLock tmpLock(_mutex); assert(soundHandle && checkForProperHandle(soundHandle)); return soundHandle->channels; } bool ImuseDigiSndMgr::isEndOfRegion(soundStruct *soundHandle, int region) { - Common::StackLock tmpLock(_mutex); assert(soundHandle && checkForProperHandle(soundHandle)); assert(region >= 0 && region < soundHandle->numRegions); return soundHandle->endFlag; } int ImuseDigiSndMgr::getNumRegions(soundStruct *soundHandle) { - Common::StackLock tmpLock(_mutex); assert(soundHandle && checkForProperHandle(soundHandle)); return soundHandle->numRegions; } int ImuseDigiSndMgr::getNumJumps(soundStruct *soundHandle) { - Common::StackLock tmpLock(_mutex); assert(soundHandle && checkForProperHandle(soundHandle)); return soundHandle->numJumps; } int ImuseDigiSndMgr::getNumMarkers(soundStruct *soundHandle) { - Common::StackLock tmpLock(_mutex); assert(soundHandle && checkForProperHandle(soundHandle)); return soundHandle->numMarkers; } int ImuseDigiSndMgr::getJumpIdByRegionId(soundStruct *soundHandle, int number) { - Common::StackLock tmpLock(_mutex); assert(soundHandle && checkForProperHandle(soundHandle)); assert(number >= 0 && number < soundHandle->numRegions); for (int l = 0; l < soundHandle->numJumps; l++) { @@ -353,7 +340,6 @@ int ImuseDigiSndMgr::getJumpIdByRegionId(soundStruct *soundHandle, int number) { } void ImuseDigiSndMgr::getSyncSizeAndPtrById(soundStruct *soundHandle, int number, int32 &sync_size, byte **sync_ptr) { - Common::StackLock tmpLock(_mutex); assert(soundHandle && checkForProperHandle(soundHandle)); assert(number >= 0); if (number < soundHandle->numSyncs) { @@ -366,7 +352,6 @@ void ImuseDigiSndMgr::getSyncSizeAndPtrById(soundStruct *soundHandle, int number } int ImuseDigiSndMgr::getRegionIdByHookId(soundStruct *soundHandle, int number) { - Common::StackLock tmpLock(_mutex); assert(soundHandle && checkForProperHandle(soundHandle)); for (int l = 0; l < soundHandle->numJumps; l++) { if (soundHandle->jump[l].hookId == number) { @@ -382,28 +367,24 @@ int ImuseDigiSndMgr::getRegionIdByHookId(soundStruct *soundHandle, int number) { } int ImuseDigiSndMgr::getJumpHookId(soundStruct *soundHandle, int number) { - Common::StackLock tmpLock(_mutex); assert(soundHandle && checkForProperHandle(soundHandle)); assert(number >= 0 && number < soundHandle->numJumps); return soundHandle->jump[number].hookId; } int ImuseDigiSndMgr::getJumpFade(soundStruct *soundHandle, int number) { - Common::StackLock tmpLock(_mutex); assert(soundHandle && checkForProperHandle(soundHandle)); assert(number >= 0 && number < soundHandle->numJumps); return soundHandle->jump[number].fadeDelay; } char *ImuseDigiSndMgr::getMarker(soundStruct *soundHandle, int number) { - Common::StackLock tmpLock(_mutex); assert(soundHandle && checkForProperHandle(soundHandle)); assert(number >= 0 && number < soundHandle->numMarkers); return (char *)(soundHandle->marker[number].name); } int32 ImuseDigiSndMgr::getDataFromRegion(soundStruct *soundHandle, int region, byte **buf, int32 offset, int32 size) { - Common::StackLock tmpLock(_mutex); assert(soundHandle && checkForProperHandle(soundHandle)); assert(buf && offset >= 0 && size >= 0); assert(region >= 0 && region < soundHandle->numRegions); diff --git a/scumm/imuse_digi/dimuse_sndmgr.h b/scumm/imuse_digi/dimuse_sndmgr.h index 4131cb8313..b87bf37d8e 100644 --- a/scumm/imuse_digi/dimuse_sndmgr.h +++ b/scumm/imuse_digi/dimuse_sndmgr.h @@ -103,7 +103,6 @@ private: void prepareSound(byte *ptr, int slot); ScummEngine *_vm; - OSystem::MutexRef _mutex; byte _disk; BundleDirCache *_cacheBundleDir; |