diff options
author | johndoe123 | 2012-09-27 17:07:41 +0000 |
---|---|---|
committer | Willem Jan Palenstijn | 2013-05-08 20:43:43 +0200 |
commit | a5986fd7222f32dfb00487542086cdd765a39208 (patch) | |
tree | 860f13d4f6ebe0162e8ef5e0d1f2f497dc7f308a /engines/neverhood/sound.cpp | |
parent | 8bdddfdb02c0327af2985b81b4803b79de5a2b33 (diff) | |
download | scummvm-rg350-a5986fd7222f32dfb00487542086cdd765a39208.tar.gz scummvm-rg350-a5986fd7222f32dfb00487542086cdd765a39208.tar.bz2 scummvm-rg350-a5986fd7222f32dfb00487542086cdd765a39208.zip |
NEVERHOOD: Fix resource file reading by introducing SafeMutexedSeekableSubReadStream which locks a mutex during reads and also lock the same mutex in BlbArchive::load; loading resources while music is playing shouldn't mess up the file position now
- Fix loading of non-existent resources (not elegant and not checked everywhere yet, the resource system is subject to a minor rewrite anyway)
- Rename more Klayman stuff
Diffstat (limited to 'engines/neverhood/sound.cpp')
-rw-r--r-- | engines/neverhood/sound.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/engines/neverhood/sound.cpp b/engines/neverhood/sound.cpp index df66c6b777..c1db48c637 100644 --- a/engines/neverhood/sound.cpp +++ b/engines/neverhood/sound.cpp @@ -306,11 +306,11 @@ void SoundMan::update() { if (musicItem->_countdown) { --musicItem->_countdown; } else if (musicItem->_play && !musicItem->_musicResource->isPlaying()) { - debug("SoundMan: play music %08X (fade %d)", musicItem->_musicFileHash, musicItem->_fadeVolumeStep); + debug(1, "SoundMan: play music %08X (fade %d)", musicItem->_musicFileHash, musicItem->_fadeVolumeStep); musicItem->_musicResource->play(musicItem->_fadeVolumeStep); musicItem->_fadeVolumeStep = 0; } else if (musicItem->_stop) { - debug("SoundMan: stop music %08X (fade %d)", musicItem->_musicFileHash, musicItem->_fadeVolumeStep); + debug(1, "SoundMan: stop music %08X (fade %d)", musicItem->_musicFileHash, musicItem->_fadeVolumeStep); musicItem->_musicResource->stop(musicItem->_fadeVolumeStep); musicItem->_fadeVolumeStep = 0; musicItem->_stop = false; @@ -529,13 +529,11 @@ int16 AudioResourceMan::addSound(uint32 fileHash) { soundItem->_isPlaying = false; soundItem->_volume = 100; soundItem->_panning = 50; - for (uint i = 0; i < _soundItems.size(); ++i) if (!_soundItems[i]) { _soundItems[i] = soundItem; return i; } - int16 soundIndex = (int16)_soundItems.size(); _soundItems.push_back(soundItem); return soundIndex; @@ -591,6 +589,9 @@ void AudioResourceMan::playSound(int16 soundIndex, bool looping) { AudioResourceManSoundItem *soundItem = _soundItems[soundIndex]; if (!soundItem->_data) loadSound(soundIndex); + + if (!soundItem->_data) + return; uint32 soundSize = _vm->_res->getResourceSize(soundItem->_resourceHandle); Common::MemoryReadStream *stream = new Common::MemoryReadStream(soundItem->_data, soundSize, DisposeAfterUse::NO); @@ -600,7 +601,7 @@ void AudioResourceMan::playSound(int16 soundIndex, bool looping) { _vm->_mixer->playStream(Audio::Mixer::kSFXSoundType, &soundItem->_soundHandle, audioStream, -1, VOLUME(soundItem->_volume), PANNING(soundItem->_panning)); - debug("playing sound %08X", soundItem->_fileHash); + debug(1, "playing sound %08X", soundItem->_fileHash); soundItem->_isPlaying = true; |