From aa6ec62e9db78db12912d0e48025241c5d7ef4f7 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Sun, 22 Feb 2004 14:11:16 +0000 Subject: Patch #885904 (Flac Support) with some tweaks by me svn-id: r12984 --- scumm/sound.cpp | 42 +++++++++++++++++++++++++++++++----------- scumm/sound.h | 2 +- 2 files changed, 32 insertions(+), 12 deletions(-) (limited to 'scumm') diff --git a/scumm/sound.cpp b/scumm/sound.cpp index 519ff980db..61e4da3d77 100644 --- a/scumm/sound.cpp +++ b/scumm/sound.cpp @@ -37,6 +37,7 @@ #include "sound/mp3.h" #include "sound/voc.h" #include "sound/vorbis.h" +#include "sound/flac.h" namespace Scumm { @@ -831,17 +832,25 @@ void Sound::pauseSounds(bool pause) { void Sound::startSfxSound(File *file, int file_size, PlayingSoundHandle *handle, int id) { - AudioStream *input = 0; + AudioStream *input = NULL; if (file_size > 0) { - if (_vorbis_mode) { + switch (_sound_mode) { + case kMP3Mode: +#ifdef USE_MAD + input = makeMP3Stream(file, file_size); +#endif + break; + case kVorbisMode: #ifdef USE_VORBIS input = makeVorbisStream(file, file_size); #endif - } else { -#ifdef USE_MAD - input = makeMP3Stream(file, file_size); + break; + case kFlacMode: +#ifdef USE_FLAC + input = makeFlacStream(file, file_size); #endif + break; } } else { input = makeVOCStream(_sfxFile); @@ -869,13 +878,24 @@ File *Sound::openSfxFile() { * same directory */ offset_table = NULL; +#ifdef USE_FLAC + if (!file->isOpen()) { + sprintf(buf, "%s.sof", _vm->getGameName()); + if (!file->open(buf, _vm->getGameDataPath())) + file->open("monster.sof", _vm->getGameDataPath()); + if (file->isOpen()) + _sound_mode = kFlacMode; + } +#endif + #ifdef USE_MAD - sprintf(buf, "%s.so3", _vm->getGameName()); - if (!file->open(buf, _vm->getGameDataPath())) { - file->open("monster.so3", _vm->getGameDataPath()); + if (!file->isOpen()) { + sprintf(buf, "%s.so3", _vm->getGameName()); + if (!file->open(buf, _vm->getGameDataPath())) + file->open("monster.so3", _vm->getGameDataPath()); + if (file->isOpen()) + _sound_mode = kMP3Mode; } - if (file->isOpen()) - _vorbis_mode = false; #endif #ifdef USE_VORBIS @@ -884,7 +904,7 @@ File *Sound::openSfxFile() { if (!file->open(buf, _vm->getGameDataPath())) file->open("monster.sog", _vm->getGameDataPath()); if (file->isOpen()) - _vorbis_mode = true; + _sound_mode = kVorbisMode; } #endif diff --git a/scumm/sound.h b/scumm/sound.h index c785853018..97c19029de 100644 --- a/scumm/sound.h +++ b/scumm/sound.h @@ -52,7 +52,7 @@ protected: MP3OffsetTable *offset_table; // SO3 MP3 compressed audio int num_sound_effects; // SO3 MP3 compressed audio - bool _vorbis_mode; // true if using SOG, false if using SO3 + enum { kMP3Mode, kVorbisMode, kFlacMode } _sound_mode; int _currentCDSound; -- cgit v1.2.3