[Scummvm-git-logs] scummvm master -> 4adea6eaced8d6281a5d50ffaa3bfb4906af96a4
dreammaster
dreammaster at scummvm.org
Fri Feb 10 04:13:08 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:
4adea6eace TITANIC: FIxes and cleanup for instrument mixer code
Commit: 4adea6eaced8d6281a5d50ffaa3bfb4906af96a4
https://github.com/scummvm/scummvm/commit/4adea6eaced8d6281a5d50ffaa3bfb4906af96a4
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2017-02-09T22:12:56-05:00
Commit Message:
TITANIC: FIxes and cleanup for instrument mixer code
Changed paths:
engines/titanic/sound/music_wave.cpp
engines/titanic/sound/music_wave.h
engines/titanic/sound/wave_file.cpp
engines/titanic/sound/wave_file.h
diff --git a/engines/titanic/sound/music_wave.cpp b/engines/titanic/sound/music_wave.cpp
index 8f3f300..1145864 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 5b63c74..5d20525 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 a328fe1..0d9d86d 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 f37557c..5a467c8 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
More information about the Scummvm-git-logs
mailing list