diff options
author | Alyssa Milburn | 2012-08-28 15:39:00 +0200 |
---|---|---|
committer | Alyssa Milburn | 2012-08-28 15:54:12 +0200 |
commit | 31801137b5c6908edd76f357b3f29b07e9e3be84 (patch) | |
tree | 33e973717545ae27da6ba4996d0d8fe1bcd437b3 /engines/lastexpress/sound | |
parent | 35fd91793b34b72624a89f2a76f45bc8e59020d2 (diff) | |
parent | 6ab8db638e4a1d547ee67db067b5d6c3d6c940a4 (diff) | |
download | scummvm-rg350-31801137b5c6908edd76f357b3f29b07e9e3be84.tar.gz scummvm-rg350-31801137b5c6908edd76f357b3f29b07e9e3be84.tar.bz2 scummvm-rg350-31801137b5c6908edd76f357b3f29b07e9e3be84.zip |
Merge remote-tracking branch 'origin/master' into tony
Conflicts:
common/coroutines.cpp
common/coroutines.h
devtools/create_project/msbuild.cpp
devtools/create_project/visualstudio.cpp
Diffstat (limited to 'engines/lastexpress/sound')
-rw-r--r-- | engines/lastexpress/sound/entry.cpp | 27 | ||||
-rw-r--r-- | engines/lastexpress/sound/queue.cpp | 30 | ||||
-rw-r--r-- | engines/lastexpress/sound/queue.h | 2 | ||||
-rw-r--r-- | engines/lastexpress/sound/sound.cpp | 25 |
4 files changed, 56 insertions, 28 deletions
diff --git a/engines/lastexpress/sound/entry.cpp b/engines/lastexpress/sound/entry.cpp index 44cc68a57b..3d22657124 100644 --- a/engines/lastexpress/sound/entry.cpp +++ b/engines/lastexpress/sound/entry.cpp @@ -30,11 +30,9 @@ #include "lastexpress/sound/sound.h" #include "lastexpress/graphics.h" -#include "lastexpress/helpers.h" #include "lastexpress/lastexpress.h" #include "lastexpress/resource.h" -#include "common/stream.h" namespace LastExpress { @@ -47,6 +45,8 @@ namespace LastExpress { SoundEntry::SoundEntry(LastExpressEngine *engine) : _engine(engine) { _type = kSoundTypeNone; + _currentDataPtr = NULL; + _blockCount = 0; _time = 0; @@ -71,7 +71,13 @@ SoundEntry::~SoundEntry() { // Entries that have been queued will have their streamed disposed automatically if (!_soundStream) SAFE_DELETE(_stream); - delete _soundStream; + + SAFE_DELETE(_soundStream); + + free(_currentDataPtr); + + _subtitle = NULL; + _stream = NULL; // Zero passed pointers _engine = NULL; @@ -110,10 +116,8 @@ void SoundEntry::close() { } void SoundEntry::play() { - if (!_stream) { - warning("[SoundEntry::play] stream has been disposed"); - return; - } + if (!_stream) + error("[SoundEntry::play] stream has been disposed"); // Prepare sound stream if (!_soundStream) @@ -277,7 +281,7 @@ bool SoundEntry::updateSound() { int l = strlen(sub) + 1; if (l - 1 > 4) - sub[l - 1 - 4] = 0; + sub[l - (1 + 4)] = 0; showSubtitle(sub); } } else { @@ -393,6 +397,10 @@ SubtitleEntry::SubtitleEntry(LastExpressEngine *engine) : _engine(engine) { SubtitleEntry::~SubtitleEntry() { SAFE_DELETE(_data); + + // Zero-out passed pointers + _sound = NULL; + _engine = NULL; } void SubtitleEntry::load(Common::String filename, SoundEntry *soundEntry) { @@ -423,6 +431,9 @@ void SubtitleEntry::loadData() { } void SubtitleEntry::setupAndDraw() { + if (!_sound) + error("[SubtitleEntry::setupAndDraw] Sound entry not initialized"); + if (!_data) { _data = new SubtitleManager(_engine->getFont()); _data->load(getArchive(_filename)); diff --git a/engines/lastexpress/sound/queue.cpp b/engines/lastexpress/sound/queue.cpp index 33b4c06793..8904b48930 100644 --- a/engines/lastexpress/sound/queue.cpp +++ b/engines/lastexpress/sound/queue.cpp @@ -26,6 +26,7 @@ #include "lastexpress/game/state.h" #include "lastexpress/sound/entry.h" +#include "lastexpress/sound/sound.h" #include "lastexpress/helpers.h" #include "lastexpress/lastexpress.h" @@ -39,6 +40,7 @@ SoundQueue::SoundQueue(LastExpressEngine *engine) : _engine(engine) { _subtitlesFlag = 0; _currentSubtitle = NULL; + //_soundCacheData = NULL; } SoundQueue::~SoundQueue() { @@ -51,6 +53,7 @@ SoundQueue::~SoundQueue() { _subtitles.clear(); _currentSubtitle = NULL; + //SAFE_DELETE(_soundCacheData); // Zero passed pointers _engine = NULL; @@ -64,6 +67,8 @@ void SoundQueue::handleTimer() { for (Common::List<SoundEntry *>::iterator i = _soundList.begin(); i != _soundList.end(); ++i) { SoundEntry *entry = (*i); + if (entry == NULL) + error("[SoundQueue::handleTimer] Invalid entry found in sound queue"); // When the entry has stopped playing, we remove his buffer if (entry->isFinished()) { @@ -120,6 +125,8 @@ void SoundQueue::updateQueue() { for (Common::List<SoundEntry *>::iterator it = _soundList.begin(); it != _soundList.end(); ++it) { SoundEntry *entry = *it; + if (entry == NULL) + error("[SoundQueue::updateQueue] Invalid entry found in sound queue"); // Original removes the entry data from the cache and sets the archive as not loaded // and if the sound data buffer is not full, loads a new entry to be played based on @@ -134,7 +141,7 @@ void SoundQueue::updateQueue() { // Original update the current entry, loading another set of samples to be decoded - getFlags()->flag_3 = 0; + getFlags()->flag_3 = false; --_flag; } @@ -176,6 +183,8 @@ void SoundQueue::clearQueue() { for (Common::List<SoundEntry *>::iterator i = _soundList.begin(); i != _soundList.end(); ++i) { SoundEntry *entry = (*i); + if (entry == NULL) + error("[SoundQueue::clearQueue] Invalid entry found in sound queue"); // Delete entry entry->close(); @@ -340,13 +349,14 @@ void SoundQueue::updateSubtitles() { return; } + if (!subtitle) + return; + if (_subtitlesFlag & 1) subtitle->drawOnScreen(); - if (subtitle) { - subtitle->loadData(); - subtitle->setupAndDraw(); - } + subtitle->loadData(); + subtitle->setupAndDraw(); } ////////////////////////////////////////////////////////////////////////// @@ -368,7 +378,15 @@ void SoundQueue::saveLoadWithSerializer(Common::Serializer &s) { (*i)->saveLoadWithSerializer(s); } else { warning("[Sound::saveLoadWithSerializer] Loading not implemented"); - s.skip(numEntries * 64); + + uint32 unusedDataSize = numEntries * 64; + if (s.isLoading()) { + byte *empty = (byte *)malloc(unusedDataSize); + s.syncBytes(empty, unusedDataSize); + free(empty); + } else { + s.skip(unusedDataSize); + } } } diff --git a/engines/lastexpress/sound/queue.h b/engines/lastexpress/sound/queue.h index 75fe06883a..e1f9be1cf7 100644 --- a/engines/lastexpress/sound/queue.h +++ b/engines/lastexpress/sound/queue.h @@ -106,7 +106,7 @@ private: // Entries Common::List<SoundEntry *> _soundList; ///< List of all sound entries - void *_soundCacheData; + //void *_soundCacheData; // Subtitles int _subtitlesFlag; diff --git a/engines/lastexpress/sound/sound.cpp b/engines/lastexpress/sound/sound.cpp index 2f7bb4a601..319f7cd4f4 100644 --- a/engines/lastexpress/sound/sound.cpp +++ b/engines/lastexpress/sound/sound.cpp @@ -33,7 +33,6 @@ #include "lastexpress/sound/entry.h" #include "lastexpress/sound/queue.h" -#include "lastexpress/helpers.h" #include "lastexpress/graphics.h" #include "lastexpress/lastexpress.h" #include "lastexpress/resource.h" @@ -675,7 +674,7 @@ const char *SoundManager::getDialogName(EntityIndex entity) const { ////////////////////////////////////////////////////////////////////////// // Letters & Messages ////////////////////////////////////////////////////////////////////////// -void SoundManager::readText(int id){ +void SoundManager::readText(int id) { if (!_queue->isBuffered(kEntityTables4)) return; @@ -1330,23 +1329,23 @@ void SoundManager::playLoopingSound(int param) { } } else { switch (getEntityData(kEntityPlayer)->car) { - case 1: - case 6: + case kCarBaggageRear: + case kCarBaggage: partNumber = 4; break; - case 2: - case 3: - case 4: - case 5: + case kCarKronos: + case kCarGreenSleeping: + case kCarRedSleeping: + case kCarRestaurant: partNumber = 1; break; - case 7: + case kCarCoalTender: partNumber = 5; break; - case 8: + case kCarLocomotive: partNumber = 99; break; - case 9: + case kCar9: partNumber = 3; break; default: @@ -1357,13 +1356,13 @@ void SoundManager::playLoopingSound(int param) { } if (partNumber != 99) - sprintf(tmp, "LOOP%d%c.SND", partNumber, _engine->getRandom().getRandomNumber(numLoops[partNumber] - 1) + 'A'); + sprintf(tmp, "LOOP%d%c.SND", partNumber, (char)(_engine->getRandom().getRandomNumber(numLoops[partNumber] - 1) + 'A')); } if (getFlags()->flag_3) fnameLen = 5; - if (!entry || scumm_strnicmp(entry->getName2().c_str(), tmp, fnameLen)) { + if (!entry || scumm_strnicmp(entry->getName2().c_str(), tmp, (uint)fnameLen)) { _loopingSoundDuration = _engine->getRandom().getRandomNumber(319) + 260; if (partNumber != 99) { |