diff options
author | Paul Gilbert | 2017-02-09 22:37:51 -0500 |
---|---|---|
committer | Paul Gilbert | 2017-02-09 22:37:51 -0500 |
commit | e942131e22e412a6044c8bf1419c13ece7acd215 (patch) | |
tree | 6185d1f7ccc9c6d47f770c5a5ef569d8a8f37710 /engines/titanic/sound | |
parent | 4adea6eaced8d6281a5d50ffaa3bfb4906af96a4 (diff) | |
download | scummvm-rg350-e942131e22e412a6044c8bf1419c13ece7acd215.tar.gz scummvm-rg350-e942131e22e412a6044c8bf1419c13ece7acd215.tar.bz2 scummvm-rg350-e942131e22e412a6044c8bf1419c13ece7acd215.zip |
TITANIC: Extra sanity checks before locking CWaveFiles for access
Diffstat (limited to 'engines/titanic/sound')
-rw-r--r-- | engines/titanic/sound/wave_file.cpp | 12 | ||||
-rw-r--r-- | engines/titanic/sound/wave_file.h | 2 |
2 files changed, 8 insertions, 6 deletions
diff --git a/engines/titanic/sound/wave_file.cpp b/engines/titanic/sound/wave_file.cpp index 0d9d86d714..e49c44d76d 100644 --- a/engines/titanic/sound/wave_file.cpp +++ b/engines/titanic/sound/wave_file.cpp @@ -20,6 +20,7 @@ * */ +#include "audio/decoders/raw.h" #include "audio/decoders/wave.h" #include "common/memstream.h" #include "titanic/sound/wave_file.h" @@ -30,13 +31,13 @@ namespace Titanic { CWaveFile::CWaveFile() : _soundManager(nullptr), _audioStream(nullptr), _waveData(nullptr), _waveSize(0), _dataSize(0), _headerSize(0), - _soundType(Audio::Mixer::kPlainSoundType) { + _rate(0), _flags(0), _soundType(Audio::Mixer::kPlainSoundType) { setup(); } CWaveFile::CWaveFile(QSoundManager *owner) : _soundManager(owner), _audioStream(nullptr), _waveData(nullptr), _waveSize(0), _dataSize(0), _headerSize(0), - _soundType(Audio::Mixer::kPlainSoundType) { + _rate(0), _flags(0), _soundType(Audio::Mixer::kPlainSoundType) { setup(); } @@ -137,9 +138,7 @@ void CWaveFile::load(byte *data, uint size) { // Parse the wave header Common::MemoryReadStream wavStream(data, size, DisposeAfterUse::NO); - int rate; - byte flags; - Audio::loadWAVFromStream(wavStream, _dataSize, rate, flags); + Audio::loadWAVFromStream(wavStream, _dataSize, _rate, _flags); _headerSize = wavStream.pos(); } @@ -168,7 +167,8 @@ void CWaveFile::reset() { const uint16 *CWaveFile::lock() { switch (_loadMode) { case LOADMODE_SCUMMVM: - assert(_waveData); + assert(_waveData && _rate == 22050); + assert(_flags == (Audio::FLAG_LITTLE_ENDIAN | Audio::FLAG_16BITS)); return (uint16 *)(_waveData + _headerSize); default: diff --git a/engines/titanic/sound/wave_file.h b/engines/titanic/sound/wave_file.h index 5a467c8fd5..b5303205c0 100644 --- a/engines/titanic/sound/wave_file.h +++ b/engines/titanic/sound/wave_file.h @@ -41,6 +41,8 @@ private: int _waveSize; int _dataSize; int _headerSize; + int _rate; + byte _flags; QSoundManager *_soundManager; Audio::SeekableAudioStream *_audioStream; Audio::SoundHandle _soundHandle; |