aboutsummaryrefslogtreecommitdiff
path: root/simon/sound.cpp
diff options
context:
space:
mode:
authorMax Horn2004-02-22 14:11:16 +0000
committerMax Horn2004-02-22 14:11:16 +0000
commitaa6ec62e9db78db12912d0e48025241c5d7ef4f7 (patch)
tree0afae2b795f07b9bd1c00dc75af3dca3864dac5f /simon/sound.cpp
parent6db3a8819e7ef847f6aefac8e40f542cad006481 (diff)
downloadscummvm-rg350-aa6ec62e9db78db12912d0e48025241c5d7ef4f7.tar.gz
scummvm-rg350-aa6ec62e9db78db12912d0e48025241c5d7ef4f7.tar.bz2
scummvm-rg350-aa6ec62e9db78db12912d0e48025241c5d7ef4f7.zip
Patch #885904 (Flac Support) with some tweaks by me
svn-id: r12984
Diffstat (limited to 'simon/sound.cpp')
-rw-r--r--simon/sound.cpp41
1 files changed, 41 insertions, 0 deletions
diff --git a/simon/sound.cpp b/simon/sound.cpp
index 44201899f8..1d4dd92c3b 100644
--- a/simon/sound.cpp
+++ b/simon/sound.cpp
@@ -241,6 +241,30 @@ void VorbisSound::playSound(uint sound, PlayingSoundHandle *handle, byte flags)
}
#endif
+#ifdef USE_FLAC
+class FlacSound : public BaseSound {
+public:
+ FlacSound(SoundMixer *mixer, File *file, uint32 base = 0) : BaseSound(mixer, file, base) {};
+ void playSound(uint sound, PlayingSoundHandle *handle, byte flags);
+};
+
+void FlacSound::playSound(uint sound, PlayingSoundHandle *handle, byte flags)
+{
+ if (_offsets == NULL)
+ return;
+
+ _file->seek(_offsets[sound], SEEK_SET);
+
+ int i = 1;
+ while (_offsets[sound + i] == _offsets[sound])
+ i++;
+
+ uint32 size = _offsets[sound + i] - _offsets[sound];
+
+ _mixer->playFlac(handle, _file, size);
+}
+#endif
+
Sound::Sound(const byte game, const GameSpecificSettings *gss, const Common::String &gameDataPath, SoundMixer *mixer)
: _game(game), _gameDataPath(gameDataPath), _mixer(mixer) {
_voice = 0;
@@ -259,6 +283,15 @@ Sound::Sound(const byte game, const GameSpecificSettings *gss, const Common::Str
File *file = new File();
const char *s;
+#ifdef USE_FLAC
+ if (!_voice && gss->flac_filename && gss->flac_filename[0]) {
+ file->open(gss->flac_filename, gameDataPath);
+ if (file->isOpen()) {
+ _voice_file = true;
+ _voice = new FlacSound(_mixer, file);
+ }
+ }
+#endif
#ifdef USE_MAD
if (!_voice && gss->mp3_filename && gss->mp3_filename[0]) {
file->open(gss->mp3_filename, gameDataPath);
@@ -341,6 +374,14 @@ Sound::Sound(const byte game, const GameSpecificSettings *gss, const Common::Str
}
}
#endif
+#ifdef USE_FLAC
+ if (!_effects && gss->flac_effects_filename && gss->flac_effects_filename[0]) {
+ file->open(gss->flac_effects_filename, gameDataPath);
+ if (file->isOpen()) {
+ _effects = new FlacSound(_mixer, file);
+ }
+ }
+#endif
if (!_effects) {
s = gss->voc_effects_filename;
file->open(s, gameDataPath);