aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorJohannes Schickel2009-02-01 21:11:03 +0000
committerJohannes Schickel2009-02-01 21:11:03 +0000
commit9df7f7385cbde0b05931a7faafa10d65e615e429 (patch)
treec6efa2e8b9ea400b0641f366c8a885cb65c1c118 /engines
parent8f91046af4d6056746d0dcbe92bfaa6c9349974f (diff)
downloadscummvm-rg350-9df7f7385cbde0b05931a7faafa10d65e615e429.tar.gz
scummvm-rg350-9df7f7385cbde0b05931a7faafa10d65e615e429.tar.bz2
scummvm-rg350-9df7f7385cbde0b05931a7faafa10d65e615e429.zip
- Cleanup
- This time fixed the real cause of the mismatching malloc / delete[] call. svn-id: r36191
Diffstat (limited to 'engines')
-rw-r--r--engines/kyra/sound.cpp25
1 files changed, 19 insertions, 6 deletions
diff --git a/engines/kyra/sound.cpp b/engines/kyra/sound.cpp
index a1088bf75d..f3c4789ddf 100644
--- a/engines/kyra/sound.cpp
+++ b/engines/kyra/sound.cpp
@@ -125,15 +125,28 @@ void Sound::voicePlayFromList(Common::List<const char*> fileList) {
Audio::AppendableAudioStream *out = Audio::makeAppendableAudioStream(22050, Audio::Mixer::FLAG_AUTOFREE | Audio::Mixer::FLAG_UNSIGNED);
for (Common::List<const char*>::iterator i = fileList.begin(); i != fileList.end(); i++) {
- uint32 fileSize = 0;
- uint8 *file = _vm->resource()->fileData(*i, &fileSize);
- Common::MemoryReadStream vocStream(file, fileSize, false);
+ Common::SeekableReadStream *file = _vm->resource()->createReadStream(*i);
+
+ // TODO: Maybe output an warning like "file not found"?
+ if (!file)
+ continue;
int size, rate;
- uint8 *data = Audio::loadVOCFromStream(vocStream, size, rate);
- out->queueBuffer(data, size);
- delete[] file;
+ uint8 *data = Audio::loadVOCFromStream(*file, size, rate);
+ delete file;
+
+ // FIXME/HACK: While loadVOCStream uses malloc / realloc,
+ // AppendableAudioStream uses delete[] to free the passed buffer.
+ // As a consequence we just 'move' the data to a buffer allocated
+ // via new[].
+ uint8 *vocBuffer = new uint8[size];
+ assert(vocBuffer);
+ memcpy(vocBuffer, data, size);
+ free(data);
+
+ out->queueBuffer(vocBuffer, size);
}
+
out->finish();
_soundChannels[h].file = *fileList.begin();