diff options
author | Paul Gilbert | 2017-02-10 21:30:50 -0500 |
---|---|---|
committer | Paul Gilbert | 2017-02-10 21:30:50 -0500 |
commit | 75598ba6a47bed2dd2bb056f033f8f25b0975fe6 (patch) | |
tree | 317f80036d868e06f4f3103165324843be5ac3f8 /engines/titanic/sound | |
parent | 9ab1ad60bf9f83479a85ba961938db7edb1317e0 (diff) | |
download | scummvm-rg350-75598ba6a47bed2dd2bb056f033f8f25b0975fe6.tar.gz scummvm-rg350-75598ba6a47bed2dd2bb056f033f8f25b0975fe6.tar.bz2 scummvm-rg350-75598ba6a47bed2dd2bb056f033f8f25b0975fe6.zip |
TITANIC: Further sanity checking before locking wave files 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 | 1 |
2 files changed, 10 insertions, 3 deletions
diff --git a/engines/titanic/sound/wave_file.cpp b/engines/titanic/sound/wave_file.cpp index c9caddea72..0d46dc0439 100644 --- a/engines/titanic/sound/wave_file.cpp +++ b/engines/titanic/sound/wave_file.cpp @@ -65,13 +65,13 @@ bool AudioBufferStream::endOfData() const { CWaveFile::CWaveFile() : _soundManager(nullptr), _audioStream(nullptr), _waveData(nullptr), _waveSize(0), _dataSize(0), _headerSize(0), - _rate(0), _flags(0), _soundType(Audio::Mixer::kPlainSoundType) { + _rate(0), _flags(0), _wavType(0), _soundType(Audio::Mixer::kPlainSoundType) { setup(); } CWaveFile::CWaveFile(QSoundManager *owner) : _soundManager(owner), _audioStream(nullptr), _waveData(nullptr), _waveSize(0), _dataSize(0), _headerSize(0), - _rate(0), _flags(0), _soundType(Audio::Mixer::kPlainSoundType) { + _rate(0), _flags(0), _wavType(0), _soundType(Audio::Mixer::kPlainSoundType) { setup(); } @@ -170,7 +170,7 @@ void CWaveFile::load(byte *data, uint size) { // Parse the wave header Common::MemoryReadStream wavStream(data, size, DisposeAfterUse::NO); - Audio::loadWAVFromStream(wavStream, _dataSize, _rate, _flags); + Audio::loadWAVFromStream(wavStream, _dataSize, _rate, _flags, &_wavType); _headerSize = wavStream.pos(); } @@ -197,10 +197,16 @@ void CWaveFile::reset() { } const int16 *CWaveFile::lock() { + enum { kWaveFormatPCM = 1 }; + switch (_loadMode) { case LOADMODE_SCUMMVM: + // Sanity checking that only raw 16-bit LE 22Khz waves can be locked assert(_waveData && _rate == 22050); assert(_flags == (Audio::FLAG_LITTLE_ENDIAN | Audio::FLAG_16BITS)); + assert(_wavType == kWaveFormatPCM); + + // Return a pointer to the data section of the wave file return (const int16 *)(_waveData + _headerSize); default: diff --git a/engines/titanic/sound/wave_file.h b/engines/titanic/sound/wave_file.h index 8edcf63427..991ba26232 100644 --- a/engines/titanic/sound/wave_file.h +++ b/engines/titanic/sound/wave_file.h @@ -43,6 +43,7 @@ private: int _headerSize; int _rate; byte _flags; + uint16 _wavType; QSoundManager *_soundManager; Audio::SeekableAudioStream *_audioStream; private: |