diff options
-rw-r--r-- | engines/sludge/sound.cpp | 33 |
1 files changed, 31 insertions, 2 deletions
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; } |