aboutsummaryrefslogtreecommitdiff
path: root/engines/glk
diff options
context:
space:
mode:
authorPaul Gilbert2019-07-05 22:08:55 -0700
committerPaul Gilbert2019-07-06 15:27:09 -0700
commit1d2dee43d25307451b6915a6475f3a063a4fdc4b (patch)
tree9c206f11972196ff85c7832d7c2d3bf33d869f4a /engines/glk
parent2fbb8af0bcec84d6653b97edf1699e94660e62fc (diff)
downloadscummvm-rg350-1d2dee43d25307451b6915a6475f3a063a4fdc4b.tar.gz
scummvm-rg350-1d2dee43d25307451b6915a6475f3a063a4fdc4b.tar.bz2
scummvm-rg350-1d2dee43d25307451b6915a6475f3a063a4fdc4b.zip
GLK: Fix playback of Blorb AIFF chunks
Diffstat (limited to 'engines/glk')
-rw-r--r--engines/glk/blorb.cpp24
1 files changed, 20 insertions, 4 deletions
diff --git a/engines/glk/blorb.cpp b/engines/glk/blorb.cpp
index 3c60fd36fc..88d6552ffe 100644
--- a/engines/glk/blorb.cpp
+++ b/engines/glk/blorb.cpp
@@ -21,6 +21,7 @@
*/
#include "glk/blorb.h"
+#include "common/memstream.h"
namespace Glk {
@@ -64,16 +65,31 @@ const Common::ArchiveMemberPtr Blorb::getMember(const Common::String &name) cons
Common::SeekableReadStream *Blorb::createReadStreamForMember(const Common::String &name) const {
for (uint idx = 0; idx < _chunks.size(); ++idx) {
- if (_chunks[idx]._filename.equalsIgnoreCase(name)) {
+ const ChunkEntry &ce = _chunks[idx];
+
+ if (ce._filename.equalsIgnoreCase(name)) {
Common::File f;
if ((!_filename.empty() && !f.open(_filename)) ||
(_filename.empty() && !f.open(_fileNode)))
error("Reading failed");
- f.seek(_chunks[idx]._offset);
- Common::SeekableReadStream *result = f.readStream(_chunks[idx]._size);
- f.close();
+ f.seek(ce._offset);
+ Common::SeekableReadStream *result;
+
+ if (ce._id == ID_FORM) {
+ // AIFF chunks need to be wrapped in a FORM chunk for ScummVM decoder
+ byte *sound = (byte *)malloc(ce._size + 8);
+ WRITE_BE_UINT32(sound, MKTAG('F', 'O', 'R', 'M'));
+ WRITE_BE_UINT32(sound + 4, 0);
+ f.read(sound + 8, ce._size);
+ assert(READ_BE_UINT32(sound + 8) == ID_AIFF);
+
+ result = new Common::MemoryReadStream(sound, ce._size + 8, DisposeAfterUse::YES);
+ } else {
+ result = f.readStream(ce._size);
+ }
+ f.close();
return result;
}
}