[Scummvm-git-logs] scummvm master -> 75598ba6a47bed2dd2bb056f033f8f25b0975fe6

dreammaster dreammaster at scummvm.org
Sat Feb 11 03:30:57 CET 2017


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
75598ba6a4 TITANIC: Further sanity checking before locking wave files for access


Commit: 75598ba6a47bed2dd2bb056f033f8f25b0975fe6
    https://github.com/scummvm/scummvm/commit/75598ba6a47bed2dd2bb056f033f8f25b0975fe6
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2017-02-10T21:30:50-05:00

Commit Message:
TITANIC: Further sanity checking before locking wave files for access

Changed paths:
    engines/titanic/sound/wave_file.cpp
    engines/titanic/sound/wave_file.h


diff --git a/engines/titanic/sound/wave_file.cpp b/engines/titanic/sound/wave_file.cpp
index c9cadde..0d46dc0 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 8edcf63..991ba26 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:





More information about the Scummvm-git-logs mailing list