diff options
Diffstat (limited to 'engines')
-rw-r--r-- | engines/griffon/engine.cpp | 27 | ||||
-rw-r--r-- | engines/griffon/griffon.h | 12 |
2 files changed, 25 insertions, 14 deletions
diff --git a/engines/griffon/engine.cpp b/engines/griffon/engine.cpp index 191c3094ac..4d97703f3d 100644 --- a/engines/griffon/engine.cpp +++ b/engines/griffon/engine.cpp @@ -34,7 +34,9 @@ * */ +#include "audio/audiostream.h" #include "audio/decoders/vorbis.h" +#include "common/memstream.h" #include "griffon/griffon.h" #include "griffon/config.h" @@ -111,11 +113,15 @@ int GriffonEngine::Mix_getHandle() { return -1; } -int GriffonEngine::Mix_PlayChannel(Audio::SeekableAudioStream *chunk, int par3) { +int GriffonEngine::Mix_PlayChannel(DataChunk *chunk, int par3) { int ch = Mix_getHandle(); - _mixer->playStream(Audio::Mixer::kSFXSoundType, &_handles[ch], chunk, -1, Audio::Mixer::kMaxChannelVolume, - 0, DisposeAfterUse::NO, false, false); +#ifdef USE_VORBIS + Audio::SeekableAudioStream *audioStream = Audio::makeVorbisStream(new Common::MemoryReadStream(chunk->data, chunk->size), DisposeAfterUse::YES); + + _mixer->playStream(Audio::Mixer::kSFXSoundType, &_handles[ch], audioStream, -1, Audio::Mixer::kMaxChannelVolume, + 0, DisposeAfterUse::YES, false, false); +#endif // USE_VORBIS return ch; } @@ -136,20 +142,21 @@ bool GriffonEngine::Mix_Playing(int channel) { return _mixer->isSoundHandleActive(_handles[channel]); } -Audio::SeekableAudioStream *Mix_LoadWAV(const char *name) { +DataChunk *Mix_LoadWAV(const char *name) { Common::File file; - Audio::SeekableAudioStream *audioStream = NULL; + DataChunk *res = new DataChunk; file.open(name); if (!file.isOpen()) { error("Cannot open file %s", name); } -#ifdef USE_VORBIS - audioStream = Audio::makeVorbisStream(&file, DisposeAfterUse::YES); -#endif // USE_VORBIS + res->size = file.size(); + res->data = (byte *)malloc(res->size); + + file.read(res->data, res->size); - return audioStream; + return res; } @@ -5523,7 +5530,7 @@ void GriffonEngine::game_updatey() { } void GriffonEngine::game_updmusic() { - Audio::SeekableAudioStream *iplaysound = NULL; + DataChunk *iplaysound = NULL; if (menabled && config.music) { diff --git a/engines/griffon/griffon.h b/engines/griffon/griffon.h index 59255c96b6..6961d3ae0f 100644 --- a/engines/griffon/griffon.h +++ b/engines/griffon/griffon.h @@ -41,7 +41,6 @@ #include "common/random.h" #include "engines/engine.h" -#include "audio/audiostream.h" #include "audio/mixer.h" #include "graphics/transparent_surface.h" @@ -232,6 +231,11 @@ struct ANIMSET2TYPE { int h; }; +struct DataChunk { + byte *data; + int size; +}; + class GriffonEngine : public Engine { public: GriffonEngine(OSystem *syst); @@ -306,7 +310,7 @@ private: void Mix_Volume(int channel, int volume); int Mix_getHandle(); - int Mix_PlayChannel(Audio::SeekableAudioStream *chunk, int par3); + int Mix_PlayChannel(DataChunk *chunk, int par3); void Mix_Pause(int channel); void Mix_HaltChannel(int channel); void Mix_Resume(int channel); @@ -417,13 +421,13 @@ private: int lastnpc; // music info - Audio::SeekableAudioStream *mgardens, *mgardens2, *mgardens3, *mgardens4, *mboss, *mmenu, *mendofgame; + DataChunk *mgardens, *mgardens2, *mgardens3, *mgardens4, *mboss, *mmenu, *mendofgame; bool menabled; // CHECKME: Always true? int musicchannel, menuchannel; int pgardens, pboss, ptown, pacademy, pcitadel; int loopseta; - Audio::SeekableAudioStream *sfx[21]; + DataChunk *sfx[21]; Audio::SoundHandle _handles[SOUND_HANDLES]; Audio::Mixer *_mixer; |