[Scummvm-git-logs] scummvm master -> 715e9c6d700e7aad15e7d7b332a351bb1d9fc701
neuromancer
neuromancer at users.noreply.github.com
Fri May 21 22:50:03 UTC 2021
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
715e9c6d70 PRIVATE: improved SyncSound implementation
Commit: 715e9c6d700e7aad15e7d7b332a351bb1d9fc701
https://github.com/scummvm/scummvm/commit/715e9c6d700e7aad15e7d7b332a351bb1d9fc701
Author: neuromancer (gustavo.grieco at gmail.com)
Date: 2021-05-21T19:45:58-03:00
Commit Message:
PRIVATE: improved SyncSound implementation
Changed paths:
engines/private/funcs.cpp
engines/private/private.cpp
engines/private/private.h
diff --git a/engines/private/funcs.cpp b/engines/private/funcs.cpp
index b5881f19ba..e1de7ae041 100644
--- a/engines/private/funcs.cpp
+++ b/engines/private/funcs.cpp
@@ -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();
+
}
}
diff --git a/engines/private/private.cpp b/engines/private/private.cpp
index 51ce14253d..a6ffba3aa9 100644
--- a/engines/private/private.cpp
+++ b/engines/private/private.cpp
@@ -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);
diff --git a/engines/private/private.h b/engines/private/private.h
index efd3ace348..58a7968dcf 100644
--- a/engines/private/private.h
+++ b/engines/private/private.h
@@ -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();
More information about the Scummvm-git-logs
mailing list