diff options
author | Dmitry Iskrich | 2016-06-14 19:03:11 +0300 |
---|---|---|
committer | Eugene Sandulenko | 2016-08-03 23:40:36 +0200 |
commit | 2387e721040335db27a1f8f46a73cdf047c27a6e (patch) | |
tree | d8223909f4596b75d8bd94ebaad021d6ef3592db /engines/director/lingo | |
parent | 82094ed5c99bc96418efdde1b75018482c61e888 (diff) | |
download | scummvm-rg350-2387e721040335db27a1f8f46a73cdf047c27a6e.tar.gz scummvm-rg350-2387e721040335db27a1f8f46a73cdf047c27a6e.tar.bz2 scummvm-rg350-2387e721040335db27a1f8f46a73cdf047c27a6e.zip |
DIRECTOR: Play sound from MCI command
Diffstat (limited to 'engines/director/lingo')
-rw-r--r-- | engines/director/lingo/lingo-funcs.cpp | 27 | ||||
-rw-r--r-- | engines/director/lingo/lingo.cpp | 2 | ||||
-rw-r--r-- | engines/director/lingo/lingo.h | 8 |
3 files changed, 32 insertions, 5 deletions
diff --git a/engines/director/lingo/lingo-funcs.cpp b/engines/director/lingo/lingo-funcs.cpp index 1a878869d9..059671b04d 100644 --- a/engines/director/lingo/lingo-funcs.cpp +++ b/engines/director/lingo/lingo-funcs.cpp @@ -21,9 +21,10 @@ */ #include "engines/director/lingo/lingo.h" +#include "common/file.h" +#include "audio/decoders/wave.h" namespace Director { - enum MCITokenType { kMCITokenNone, @@ -119,11 +120,31 @@ int Lingo::func_mci(Common::String *s) { } switch (command) { - case kMCITokenOpen: + case kMCITokenOpen: { warning("MCI open file: %s, type: %s, alias: %s buffer: %s", params[0].c_str(), params[1].c_str(), params[2].c_str(), params[3].c_str()); + Common::File *file = new Common::File(); + if (!file->open(params[0])) { + warning("Failed to open %s", params[0].c_str()); + delete file; + return 0; + } + if (params[1] == "waveaudio") { + Audio::AudioStream *sound = Audio::makeWAVStream(file, DisposeAfterUse::YES); + _audioAliases[params[2]] = sound; + } + else + warning("Unhandled audio type %s", params[2].c_str()); + } break; - case kMCITokenPlay: + case kMCITokenPlay: { warning("MCI play file: %s, from: %s, to: %s, repeat: %s", params[0].c_str(), params[1].c_str(), params[2].c_str(), params[3].c_str()); + if (!_audioAliases.contains(params[0])) { + warning("Unknown alias %s", params[0].c_str()); + return 0; + } + //TODO seek + _vm->getSoundManager()->playMCI(*_audioAliases[params[0]]); + } break; default: warning("Unhandled MCI command: %s", s->c_str()); diff --git a/engines/director/lingo/lingo.cpp b/engines/director/lingo/lingo.cpp index 3c80608685..7296e7496d 100644 --- a/engines/director/lingo/lingo.cpp +++ b/engines/director/lingo/lingo.cpp @@ -66,7 +66,7 @@ struct EventHandlerType { { kEventNone, 0 }, }; -Lingo::Lingo() { +Lingo::Lingo(DirectorEngine *vm) : _vm(vm) { g_lingo = this; for (const EventHandlerType *t = &eventHanlerDescs[0]; t->handler != kEventNone; ++t) diff --git a/engines/director/lingo/lingo.h b/engines/director/lingo/lingo.h index 4f66cee0b0..4f7f925c54 100644 --- a/engines/director/lingo/lingo.h +++ b/engines/director/lingo/lingo.h @@ -25,6 +25,10 @@ #include "common/debug.h" #include "common/hashmap.h" +#include "common/hash-str.h" +#include "audio/audiostream.h" +#include "common/str.h" +#include "engines/director/director.h" namespace Director { @@ -67,7 +71,7 @@ enum LEvent { class Lingo { public: - Lingo(); + Lingo(DirectorEngine *vm); ~Lingo(); void processEvent(LEvent event, int entityId); @@ -78,6 +82,8 @@ public: private: Common::HashMap<uint32, const char *> _eventHandlerTypes; + Common::HashMap<Common::String, Audio::AudioStream *> _audioAliases; + DirectorEngine *_vm; }; } // End of namespace Director |