PRIVATE: improved SyncSound implementation

This commit is contained in:
neuromancer 2021-05-21 19:45:47 -03:00
parent 5000a24d72
commit 715e9c6d70
3 changed files with 20 additions and 0 deletions

View File

@ -112,6 +112,13 @@ static void fSyncSound(ArgArray args) {
if (s != "\"\"") {
g_private->playSound(s, 1, true, false);
while (g_private->isSoundActive())
g_private->ignoreEvents();
uint32 i = 100;
while(i--) // one second extra
g_private->ignoreEvents();
}
}

View File

@ -299,6 +299,13 @@ Common::Error PrivateEngine::run() {
return Common::kNoError;
}
void PrivateEngine::ignoreEvents() {
Common::Event event;
g_system->getEventManager()->pollEvent(event);
g_system->updateScreen();
g_system->delayMillis(10);
}
void PrivateEngine::initFuncs() {
for (const Private::FuncTable *fnc = funcTable; fnc->name; fnc++) {
Common::String name(fnc->name);
@ -987,6 +994,10 @@ void PrivateEngine::playSound(const Common::String &name, uint loops, bool stopO
_mixer->playStream(Audio::Mixer::kSFXSoundType, sh, stream, -1, Audio::Mixer::kMaxChannelVolume);
}
bool PrivateEngine::isSoundActive() {
return _mixer->isSoundIDActive(-1);
}
void PrivateEngine::playVideo(const Common::String &name) {
debugC(1, kPrivateDebugFunction, "%s(%s)", __FUNCTION__, name.c_str());
//stopSound(true);

View File

@ -186,6 +186,7 @@ public:
return true;
}
void ignoreEvents();
Common::Error loadGameStream(Common::SeekableReadStream *stream) override;
Common::Error saveGameStream(Common::WriteStream *stream, bool isAutosave = false) override;
void syncGameStream(Common::Serializer &s);
@ -271,6 +272,7 @@ public:
// Sounds
void playSound(const Common::String &, uint, bool, bool);
void stopSound(bool);
bool isSoundActive();
bool _noStopSounds;
Common::String getPaperShuffleSound();