aboutsummaryrefslogtreecommitdiff
path: root/engines/draci/sound.cpp
diff options
context:
space:
mode:
authorRobert Špalek2009-10-11 23:01:59 +0000
committerRobert Špalek2009-10-11 23:01:59 +0000
commitf71b32dd96cc524fbb433752ea2ead51e1cf02a4 (patch)
tree51ad784a13c13329955c7859aef83862b790983b /engines/draci/sound.cpp
parente2db155b1a82150a4c651a643b6a4343e810b8e9 (diff)
downloadscummvm-rg350-f71b32dd96cc524fbb433752ea2ead51e1cf02a4.tar.gz
scummvm-rg350-f71b32dd96cc524fbb433752ea2ead51e1cf02a4.tar.bz2
scummvm-rg350-f71b32dd96cc524fbb433752ea2ead51e1cf02a4.zip
Loading and caching sound samples in memory.
The sounds are not played yet, but the infrastructure is getting ready. svn-id: r44957
Diffstat (limited to 'engines/draci/sound.cpp')
-rw-r--r--engines/draci/sound.cpp21
1 files changed, 11 insertions, 10 deletions
diff --git a/engines/draci/sound.cpp b/engines/draci/sound.cpp
index bd2f68658b..8f734d1afb 100644
--- a/engines/draci/sound.cpp
+++ b/engines/draci/sound.cpp
@@ -74,6 +74,7 @@ void SoundArchive::openArchive(const Common::String &path) {
for (uint i = 0; i < _sampleCount; ++i) {
_samples[i]._offset = sampleStarts[i];
_samples[i]._length = sampleStarts[i+1] - sampleStarts[i];
+ _samples[i]._frequency = 0; // set in getSample()
_samples[i]._data = NULL;
}
if (_samples[_sampleCount-1]._offset + _samples[_sampleCount-1]._length != totalLength &&
@@ -128,7 +129,7 @@ void SoundArchive::clearCache() {
*
* Loads individual samples from an archive to memory on demand.
*/
-const SoundSample *SoundArchive::getSample(uint i) {
+const SoundSample *SoundArchive::getSample(uint i, uint freq) {
// Check whether requested file exists
if (i >= _sampleCount) {
return NULL;
@@ -140,16 +141,16 @@ const SoundSample *SoundArchive::getSample(uint i) {
// Check if file has already been opened and return that
if (_samples[i]._data) {
debugC(2, kDraciArchiverDebugLevel, "Success");
- return _samples + i;
- }
-
- // Read in the file (without the file header)
- _f->seek(_samples[i]._offset);
- _samples[i]._data = new byte[_samples[i]._length];
- _f->read(_samples[i]._data, _samples[i]._length);
+ } else {
+ // Read in the file (without the file header)
+ _f->seek(_samples[i]._offset);
+ _samples[i]._data = new byte[_samples[i]._length];
+ _f->read(_samples[i]._data, _samples[i]._length);
- debugC(3, kDraciArchiverDebugLevel, "Cached sample %d from archive %s",
- i, _path.c_str());
+ debugC(3, kDraciArchiverDebugLevel, "Cached sample %d from archive %s",
+ i, _path.c_str());
+ }
+ _samples[i]._frequency = freq;
return _samples + i;
}