From 2c3cbf444a421a4e64db43c228ee1b49dcc1d6ca Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Mon, 25 Jun 2007 20:20:59 +0000 Subject: Improvements to the SAGA compressed sound support svn-id: r27717 --- engines/saga/detection_tables.h | 26 +++++++++++++------------- engines/saga/saga.h | 3 ++- engines/saga/sndres.cpp | 28 +++++++++++----------------- engines/saga/sound.cpp | 2 +- engines/saga/sound.h | 1 - 5 files changed, 27 insertions(+), 33 deletions(-) diff --git a/engines/saga/detection_tables.h b/engines/saga/detection_tables.h index 4cdc2cca6c..5fc3a70c92 100644 --- a/engines/saga/detection_tables.h +++ b/engines/saga/detection_tables.h @@ -500,7 +500,7 @@ static const SAGAGameDescription gameDescriptions[] = { }, GType_ITE, GID_ITE_MACCD, - GF_BIG_ENDIAN_DATA | GF_WYRMKEEP | GF_CD_FX, + GF_BIG_ENDIAN_DATA | GF_WYRMKEEP | GF_CD_FX | GF_COMPRESSED_SOUNDS, ITE_DEFAULT_SCENE, &ITE_Resources, ARRAYSIZE(ITEWINDEMO_GameFonts), @@ -695,7 +695,7 @@ static const SAGAGameDescription gameDescriptions[] = { }, GType_ITE, GID_ITE_MULTICD, - GF_WYRMKEEP | GF_CD_FX, + GF_WYRMKEEP | GF_CD_FX | GF_COMPRESSED_SOUNDS, ITE_DEFAULT_SCENE, &ITE_Resources, ARRAYSIZE(ITECD_GameFonts), @@ -757,7 +757,7 @@ static const SAGAGameDescription gameDescriptions[] = { }, GType_ITE, GID_ITE_LINCD, - GF_WYRMKEEP | GF_CD_FX, + GF_WYRMKEEP | GF_CD_FX | GF_COMPRESSED_SOUNDS, ITE_DEFAULT_SCENE, &ITE_Resources, ARRAYSIZE(ITECD_GameFonts), @@ -817,7 +817,7 @@ static const SAGAGameDescription gameDescriptions[] = { }, GType_ITE, GID_ITE_WINCD, - GF_WYRMKEEP | GF_CD_FX, + GF_WYRMKEEP | GF_CD_FX | GF_COMPRESSED_SOUNDS, ITE_DEFAULT_SCENE, &ITE_Resources, ARRAYSIZE(ITECD_GameFonts), @@ -877,7 +877,7 @@ static const SAGAGameDescription gameDescriptions[] = { }, GType_ITE, GID_ITE_CD_G, - GF_CD_FX, + GF_CD_FX | GF_COMPRESSED_SOUNDS, ITE_DEFAULT_SCENE, &ITE_Resources, ARRAYSIZE(ITECD_GameFonts), @@ -939,7 +939,7 @@ static const SAGAGameDescription gameDescriptions[] = { }, GType_ITE, GID_ITE_CD_G2, - GF_CD_FX, + GF_CD_FX | GF_COMPRESSED_SOUNDS, ITE_DEFAULT_SCENE, &ITE_Resources, ARRAYSIZE(ITECD_GameFonts), @@ -1001,7 +1001,7 @@ static const SAGAGameDescription gameDescriptions[] = { }, GType_ITE, GID_ITE_CD_DE, - GF_CD_FX, + GF_CD_FX | GF_COMPRESSED_SOUNDS, ITE_DEFAULT_SCENE, &ITE_Resources, ARRAYSIZE(ITECD_GameFonts), @@ -1063,7 +1063,7 @@ static const SAGAGameDescription gameDescriptions[] = { }, GType_ITE, GID_ITE_CD_DE2, - GF_CD_FX, + GF_CD_FX | GF_COMPRESSED_SOUNDS, ITE_DEFAULT_SCENE, &ITE_Resources, ARRAYSIZE(ITECD_GameFonts), @@ -1123,7 +1123,7 @@ static const SAGAGameDescription gameDescriptions[] = { }, GType_ITE, GID_ITE_CD, - GF_CD_FX, + GF_CD_FX | GF_COMPRESSED_SOUNDS, ITE_DEFAULT_SCENE, &ITE_Resources, ARRAYSIZE(ITECD_GameFonts), @@ -1181,7 +1181,7 @@ static const SAGAGameDescription gameDescriptions[] = { }, GType_ITE, GID_ITE_DISK_DE, - 0, + GF_COMPRESSED_SOUNDS, ITE_DEFAULT_SCENE, &ITE_Resources, ARRAYSIZE(ITEDISK_GameFonts), @@ -1241,7 +1241,7 @@ static const SAGAGameDescription gameDescriptions[] = { }, GType_ITE, GID_ITE_DISK_DE2, - 0, + GF_COMPRESSED_SOUNDS, ITE_DEFAULT_SCENE, &ITE_Resources, ARRAYSIZE(ITEDISK_GameFonts), @@ -1299,7 +1299,7 @@ static const SAGAGameDescription gameDescriptions[] = { }, GType_ITE, GID_ITE_DISK_G, - 0, + GF_COMPRESSED_SOUNDS, ITE_DEFAULT_SCENE, &ITE_Resources, ARRAYSIZE(ITEDISK_GameFonts), @@ -1359,7 +1359,7 @@ static const SAGAGameDescription gameDescriptions[] = { }, GType_ITE, GID_ITE_DISK_G2, - 0, + GF_COMPRESSED_SOUNDS, ITE_DEFAULT_SCENE, &ITE_Resources, ARRAYSIZE(ITEDISK_GameFonts), diff --git a/engines/saga/saga.h b/engines/saga/saga.h index c5038e5c5d..19d965643a 100644 --- a/engines/saga/saga.h +++ b/engines/saga/saga.h @@ -152,7 +152,8 @@ enum GameFeatures { GF_BIG_ENDIAN_DATA = 1 << 0, GF_WYRMKEEP = 1 << 1, GF_CD_FX = 1 << 2, - GF_SCENE_SUBSTITUTES = 1 << 3 + GF_SCENE_SUBSTITUTES = 1 << 3, + GF_COMPRESSED_SOUNDS = 1 << 4 }; enum VerbTypeIds { diff --git a/engines/saga/sndres.cpp b/engines/saga/sndres.cpp index 9cf1770d43..31fab58657 100644 --- a/engines/saga/sndres.cpp +++ b/engines/saga/sndres.cpp @@ -176,18 +176,18 @@ bool SndRes::load(ResourceContext *context, uint32 resourceId, SoundBuffer &buff resourceType = kSoundVOC; } else if (!memcmp(soundResource, "RIFF", 4) != 0) { resourceType = kSoundWAV; - } else if (soundResource[0] == char(0)) { - readS.seek(1); // Skip compression identifier byte - uint16 test = readS.readUint16LE(); // the frequency - // the sound's frequency is not supposed to be 0, if it is then it's an empty sound, - // so don't treat it as MP3 - if (test > 0) + } + + if (_vm->getFeatures() & GF_COMPRESSED_SOUNDS) { + if (soundResource[0] == char(0)) { resourceType = kSoundMP3; - } else if (soundResource[0] == char(1)) { - resourceType = kSoundOGG; - } else if (soundResource[0] == char(2)) { - resourceType = kSoundFLAC; + } else if (soundResource[0] == char(1)) { + resourceType = kSoundOGG; + } else if (soundResource[0] == char(2)) { + resourceType = kSoundFLAC; + } } + } @@ -198,7 +198,6 @@ bool SndRes::load(ResourceContext *context, uint32 resourceId, SoundBuffer &buff buffer.sampleBits = soundInfo->sampleBits; buffer.size = soundResourceLength; buffer.stereo = soundInfo->stereo; - buffer.isCompressed = false; if (onlyHeader) { buffer.buffer = NULL; free(soundResource); @@ -213,7 +212,6 @@ bool SndRes::load(ResourceContext *context, uint32 resourceId, SoundBuffer &buff buffer.sampleBits = soundInfo->sampleBits; buffer.size = soundResourceLength - 36; buffer.stereo = soundInfo->stereo; - buffer.isCompressed = false; if (onlyHeader) { buffer.buffer = NULL; } else { @@ -229,7 +227,6 @@ bool SndRes::load(ResourceContext *context, uint32 resourceId, SoundBuffer &buff buffer.sampleBits = soundInfo->sampleBits; buffer.stereo = soundInfo->stereo; buffer.size = soundResourceLength * 4; - buffer.isCompressed = false; if (onlyHeader) { buffer.buffer = NULL; free(soundResource); @@ -252,7 +249,6 @@ bool SndRes::load(ResourceContext *context, uint32 resourceId, SoundBuffer &buff buffer.stereo = false; buffer.isSigned = false; buffer.size = size; - buffer.isCompressed = false; if (onlyHeader) { buffer.buffer = NULL; free(data); @@ -270,7 +266,6 @@ bool SndRes::load(ResourceContext *context, uint32 resourceId, SoundBuffer &buff buffer.stereo = ((flags & Audio::Mixer::FLAG_STEREO) != 0); buffer.isSigned = true; buffer.size = size; - buffer.isCompressed = false; if (onlyHeader) { buffer.buffer = NULL; } else { @@ -294,7 +289,6 @@ bool SndRes::load(ResourceContext *context, uint32 resourceId, SoundBuffer &buff buffer.originalSize = readS.readUint32LE(); buffer.sampleBits = readS.readByte(); buffer.stereo = (readS.readByte() == char(0)) ? false : true; - buffer.isCompressed = true; buffer.soundType = resourceType; buffer.soundFile = context->getFile(resourceData); buffer.fileOffset = resourceData->offset; @@ -324,7 +318,7 @@ int SndRes::getVoiceLength(uint32 resourceId) { return -1; } - if (!buffer.isCompressed) + if (!(_vm->getFeatures() & GF_COMPRESSED_SOUNDS)) msDouble = (double)buffer.size; else msDouble = (double)buffer.originalSize; diff --git a/engines/saga/sound.cpp b/engines/saga/sound.cpp index b0f4f8319b..6c2516c8a3 100644 --- a/engines/saga/sound.cpp +++ b/engines/saga/sound.cpp @@ -80,7 +80,7 @@ void Sound::playSoundBuffer(Audio::SoundHandle *handle, SoundBuffer &buffer, int if (!buffer.isSigned) flags |= Audio::Mixer::FLAG_UNSIGNED; - if (!buffer.isCompressed) { + if (!(_vm->getFeatures() & GF_COMPRESSED_SOUNDS)) { _mixer->playRaw(Audio::Mixer::kSFXSoundType, handle, buffer.buffer, buffer.size, buffer.frequency, flags, -1, volume); } else { buffer.soundFile->seek((long)buffer.fileOffset, SEEK_SET); diff --git a/engines/saga/sound.h b/engines/saga/sound.h index b75c194da4..459ade90c1 100644 --- a/engines/saga/sound.h +++ b/engines/saga/sound.h @@ -54,7 +54,6 @@ struct SoundBuffer { size_t size; size_t originalSize; bool isBigEndian; - bool isCompressed; GameSoundTypes soundType; Common::File *soundFile; size_t fileOffset; -- cgit v1.2.3