diff options
author | Torbjörn Andersson | 2003-12-19 06:51:32 +0000 |
---|---|---|
committer | Torbjörn Andersson | 2003-12-19 06:51:32 +0000 |
commit | a3310a5de932095809e21b63ee593efe213a3080 (patch) | |
tree | 08ca3807f5a6e00c6a292864742c6f447e9b7b4f /sword1/sound.cpp | |
parent | d8903123b0bd4265de03f40eaaf6bb1d2b160c3f (diff) | |
download | scummvm-rg350-a3310a5de932095809e21b63ee593efe213a3080.tar.gz scummvm-rg350-a3310a5de932095809e21b63ee593efe213a3080.tar.bz2 scummvm-rg350-a3310a5de932095809e21b63ee593efe213a3080.zip |
Make sure that playSample() gets a pointer to the original QueueElement
instead of a copy of it. Otherwise the sound engine will never notice when
a sample finishes playing since it's looking at the wrong sound handle.
For whatever reason, this also seems to fix the "game crashes occasionally
on startup with completely useless stack trace" bug for me. The crash was
easily repeatable in Valgrind for me, but the messages it produced were
just as unhelpful as the stack trace. These messages are also gone now.
svn-id: r11757
Diffstat (limited to 'sword1/sound.cpp')
-rw-r--r-- | sword1/sound.cpp | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/sword1/sound.cpp b/sword1/sound.cpp index 6b6442d106..14be42676b 100644 --- a/sword1/sound.cpp +++ b/sword1/sound.cpp @@ -76,7 +76,7 @@ void SwordSound::engine(void) { if (_fxQueue[cnt].delay > 0) { _fxQueue[cnt].delay--; if (_fxQueue[cnt].delay == 0) - playSample(_fxQueue[cnt]); + playSample(&_fxQueue[cnt]); } else { if (!_fxQueue[cnt].handle) { // sound finished _resMan->resClose(_fxList[_fxQueue[cnt].id].sampleId); @@ -128,16 +128,15 @@ void SwordSound::newScreen(uint16 screen) { // I don't think that we even have to start SFX here. } -void SwordSound::playSample(QueueElement elem) { - - uint8 *sampleData = (uint8*)_resMan->fetchRes(_fxList[elem.id].sampleId); +void SwordSound::playSample(QueueElement *elem) { + uint8 *sampleData = (uint8*)_resMan->fetchRes(_fxList[elem->id].sampleId); for (uint16 cnt = 0; cnt < MAX_ROOMS_PER_FX; cnt++) { - if (_fxList[elem.id].roomVolList[cnt].roomNo) { - if ((_fxList[elem.id].roomVolList[cnt].roomNo == (int)SwordLogic::_scriptVars[SCREEN]) || - (_fxList[elem.id].roomVolList[cnt].roomNo == -1)) { + if (_fxList[elem->id].roomVolList[cnt].roomNo) { + if ((_fxList[elem->id].roomVolList[cnt].roomNo == (int)SwordLogic::_scriptVars[SCREEN]) || + (_fxList[elem->id].roomVolList[cnt].roomNo == -1)) { - uint8 volL = _fxList[elem.id].roomVolList[cnt].leftVol * 10; - uint8 volR = _fxList[elem.id].roomVolList[cnt].rightVol * 10; + uint8 volL = _fxList[elem->id].roomVolList[cnt].leftVol * 10; + uint8 volR = _fxList[elem->id].roomVolList[cnt].rightVol * 10; int8 pan = (volR - volL) / 2; uint8 volume = (volR + volL) / 2; uint32 size = READ_LE_UINT32(sampleData + 0x28); @@ -146,7 +145,7 @@ void SwordSound::playSample(QueueElement elem) { flags = SoundMixer::FLAG_16BITS | SoundMixer::FLAG_LITTLE_ENDIAN; else flags = SoundMixer::FLAG_UNSIGNED; - _mixer->playRaw(&elem.handle, sampleData + 0x2C, size, 11025, flags, elem.id, volume, pan); + _mixer->playRaw(&elem->handle, sampleData + 0x2C, size, 11025, flags, elem->id, volume, pan); } } else break; |