aboutsummaryrefslogtreecommitdiff
path: root/engines/sludge/sound.cpp
diff options
context:
space:
mode:
authoryinsimei2017-06-07 09:20:42 +0200
committerEugene Sandulenko2017-07-13 18:27:45 +0200
commitef9438065fea8c1a58b6ebb2a8f1ecc72b2037f7 (patch)
treee4ab997c4bab48fc37aa4099a0660da29c3afc9a /engines/sludge/sound.cpp
parentda842ee14ed6a91894449ab277f93289a8744dad (diff)
downloadscummvm-rg350-ef9438065fea8c1a58b6ebb2a8f1ecc72b2037f7.tar.gz
scummvm-rg350-ef9438065fea8c1a58b6ebb2a8f1ecc72b2037f7.tar.bz2
scummvm-rg350-ef9438065fea8c1a58b6ebb2a8f1ecc72b2037f7.zip
SLUDGE: play game wav sound in a rough way
Diffstat (limited to 'engines/sludge/sound.cpp')
-rw-r--r--engines/sludge/sound.cpp33
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;
}