diff options
Diffstat (limited to 'engines')
-rw-r--r-- | engines/titanic/sound/music_wave.cpp | 12 | ||||
-rw-r--r-- | engines/titanic/sound/music_wave.h | 3 | ||||
-rw-r--r-- | engines/titanic/sound/wave_file.cpp | 6 | ||||
-rw-r--r-- | engines/titanic/sound/wave_file.h | 4 |
4 files changed, 14 insertions, 11 deletions
diff --git a/engines/titanic/sound/music_wave.cpp b/engines/titanic/sound/music_wave.cpp index 8f3f3005ba..11458642df 100644 --- a/engines/titanic/sound/music_wave.cpp +++ b/engines/titanic/sound/music_wave.cpp @@ -277,20 +277,22 @@ int CMusicWave::read(uint16 *ptr, uint size) { size = _size; if (_waveIndex != -1) { - const byte *data = _items[_waveIndex]._waveFile->lock(); + // Lock the specified wave file for access + const uint16 *data = _items[_waveIndex]._waveFile->lock(); assert(data); - const uint16 *src = (const uint16 *)data; + const uint16 *src = data; - // Loop through copying over data - for (uint idx = 0; idx < size; idx += 2, _readPos += _readIncrement) { + // Loop through merging data from the wave file into the dest buffer + for (uint idx = 0; idx < (size / sizeof(uint16)); ++idx, _readPos += _readIncrement) { uint srcPos = _readPos >> 8; if (srcPos >= _count) break; uint16 val = READ_LE_UINT16(src + srcPos); - *ptr++ = val; + *ptr++ += val; } + // Unlock the wave file _items[_waveIndex]._waveFile->unlock(data); } diff --git a/engines/titanic/sound/music_wave.h b/engines/titanic/sound/music_wave.h index 5b63c74f7f..5d205259ee 100644 --- a/engines/titanic/sound/music_wave.h +++ b/engines/titanic/sound/music_wave.h @@ -117,7 +117,8 @@ public: void setSize(uint total); /** - * Reads sound data and passes it to the provided buffer + * If there is any wave file currently specified, reads it in + * and merges it into the supplied buffer */ int read(uint16 *ptr, uint size); diff --git a/engines/titanic/sound/wave_file.cpp b/engines/titanic/sound/wave_file.cpp index a328fe1543..0d9d86d714 100644 --- a/engines/titanic/sound/wave_file.cpp +++ b/engines/titanic/sound/wave_file.cpp @@ -165,18 +165,18 @@ void CWaveFile::reset() { audioStream()->rewind(); } -const byte *CWaveFile::lock() { +const uint16 *CWaveFile::lock() { switch (_loadMode) { case LOADMODE_SCUMMVM: assert(_waveData); - return _waveData + _headerSize; + return (uint16 *)(_waveData + _headerSize); default: return nullptr; } } -void CWaveFile::unlock(const byte *ptr) { +void CWaveFile::unlock(const uint16 *ptr) { // No implementation needed in ScummVM } diff --git a/engines/titanic/sound/wave_file.h b/engines/titanic/sound/wave_file.h index f37557c7a8..5a467c8fd5 100644 --- a/engines/titanic/sound/wave_file.h +++ b/engines/titanic/sound/wave_file.h @@ -125,12 +125,12 @@ public: /** * Lock sound data for access */ - const byte *lock(); + const uint16 *lock(); /** * Unlock sound data after a prior call to lock */ - void unlock(const byte *ptr); + void unlock(const uint16 *ptr); }; } // End of namespace Titanic |