From ef9438065fea8c1a58b6ebb2a8f1ecc72b2037f7 Mon Sep 17 00:00:00 2001 From: yinsimei Date: Wed, 7 Jun 2017 09:20:42 +0200 Subject: SLUDGE: play game wav sound in a rough way --- engines/sludge/sound.cpp | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) (limited to 'engines/sludge/sound.cpp') diff --git a/engines/sludge/sound.cpp b/engines/sludge/sound.cpp index 360ad6d516..26bf17635e 100644 --- a/engines/sludge/sound.cpp +++ b/engines/sludge/sound.cpp @@ -24,14 +24,21 @@ #include "AL/alure.h" #endif +#include "common/debug.h" #include "common/file.h" +#include "audio/audiostream.h" +#include "audio/mixer.h" +#include "audio/decoders/wave.h" +#include "audio/decoders/vorbis.h" + #include "sludge/allfiles.h" #include "sludge/debug.h" #include "sludge/newfatal.h" #include "sludge/sound.h" #include "sludge/moreio.h" #include "sludge/fileset.h" +#include "sludge/sludge.h" #define MAX_SAMPLES 8 #define MAX_MODS 3 @@ -585,8 +592,30 @@ int cacheSound(int f) { } bool startSound(int f, bool loopy) { - if (soundOK) { + if (loopy) // TODO: don't consider loop sound yet at this stage + return false; + // load sound + setResourceForFatal(f); + uint32 length = openFileFromNum(f); + Common::SeekableReadStream *memImage = bigDataFile->readStream(length); + if (memImage->size() != length || bigDataFile->err()) + debug("Sound reading failed"); + Audio::AudioStream *stream = Audio::makeWAVStream(memImage, DisposeAfterUse::NO); +#ifdef USE_VORBIS + if (!stream) { + stream = Audio::makeVorbisStream(memImage, DisposeAfterUse::NO); + } +#endif + delete memImage; + if (!stream) + return false; + + // play sound + Audio::SoundHandle soundHandle; + g_sludge->_mixer->playStream(Audio::Mixer::kSFXSoundType, &soundHandle, stream, -1, Audio::Mixer::kMaxChannelVolume); #if 0 + if (soundOK) { + cacheLoopySound = loopy; int a = cacheSound(f); if (a == -1) { @@ -597,8 +626,8 @@ bool startSound(int f, bool loopy) { soundCache[a].vol = defSoundVol; playStream(a, false, loopy); -#endif } +#endif return true; } -- cgit v1.2.3