From 4b13347df8bd208d6bfbc9125d13e973f261469e Mon Sep 17 00:00:00 2001 From: sluicebox Date: Mon, 21 Oct 2019 11:09:28 -0700 Subject: SCI32: Add support for AIFF audio Used by at least LSL6 Mac CD for voices --- engines/sci/sound/audio32.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'engines/sci/sound') diff --git a/engines/sci/sound/audio32.cpp b/engines/sci/sound/audio32.cpp index 9bf08c5f74..0f08e803fb 100644 --- a/engines/sci/sound/audio32.cpp +++ b/engines/sci/sound/audio32.cpp @@ -22,6 +22,7 @@ #include "sci/sound/audio32.h" #include "audio/audiostream.h" // for SeekableAudioStream +#include "audio/decoders/aiff.h" // for makeAIFFStream #include "audio/decoders/mac_snd.h" // for makeMacSndStream #include "audio/decoders/raw.h" // for makeRawStream, RawFlags::FLAG_16BITS #include "audio/decoders/wave.h" // for makeWAVStream @@ -84,6 +85,25 @@ bool detectWaveAudio(Common::SeekableReadStream &stream) { return true; } +bool detectAIFFAudio(Common::SeekableReadStream &stream) { + const size_t initialPosition = stream.pos(); + + byte blockHeader[8]; + if (stream.read(blockHeader, sizeof(blockHeader)) != sizeof(blockHeader)) { + stream.seek(initialPosition); + return false; + } + + stream.seek(initialPosition); + const uint32 headerType = READ_BE_UINT32(blockHeader); + + if (headerType != MKTAG('F', 'O', 'R', 'M')) { + return false; + } + + return true; +} + bool detectMacSndAudio(Common::SeekableReadStream &stream) { const size_t initialPosition = stream.pos(); @@ -811,6 +831,8 @@ uint16 Audio32::play(int16 channelIndex, const ResourceId resourceId, const bool audioStream = makeSOLStream(dataStream, DisposeAfterUse::YES); } else if (detectWaveAudio(*dataStream)) { audioStream = Audio::makeWAVStream(dataStream, DisposeAfterUse::YES); + } else if (detectAIFFAudio(*dataStream)) { + audioStream = Audio::makeAIFFStream(dataStream, DisposeAfterUse::YES); } else if (detectMacSndAudio(*dataStream)) { audioStream = Audio::makeMacSndStream(dataStream, DisposeAfterUse::YES); } else { -- cgit v1.2.3