aboutsummaryrefslogtreecommitdiff
path: root/engines/sci/graphics
diff options
context:
space:
mode:
authorColin Snover2017-07-22 15:54:05 -0500
committerColin Snover2017-07-23 10:35:13 -0500
commit0beb259278dfd18757bf9484a6123edf4b44864e (patch)
treeac40430c241b1423946a87b91deb999250494f7e /engines/sci/graphics
parent6b87b13ab1ead1115cce6a897ee78c4eba45d76d (diff)
downloadscummvm-rg350-0beb259278dfd18757bf9484a6123edf4b44864e.tar.gz
scummvm-rg350-0beb259278dfd18757bf9484a6123edf4b44864e.tar.bz2
scummvm-rg350-0beb259278dfd18757bf9484a6123edf4b44864e.zip
SCI32: Improve performance when flushing events during video playback
Calling through EventManager::getSciEvent to flush events is pretty inefficient and created stalls that lead to dropped frames during the chapter 7 chase in Phantasmagoria 1. If necessary, performance could be improved further by extending Common::EventManager to expose SDL_FlushEvents, but this seems to finish in 0-1ms so should be OK for now. Refs Trac#9974, Trac#9975.
Diffstat (limited to 'engines/sci/graphics')
-rw-r--r--engines/sci/graphics/video32.cpp17
1 files changed, 4 insertions, 13 deletions
diff --git a/engines/sci/graphics/video32.cpp b/engines/sci/graphics/video32.cpp
index 22be48c0f8..e0f83c6e82 100644
--- a/engines/sci/graphics/video32.cpp
+++ b/engines/sci/graphics/video32.cpp
@@ -56,18 +56,6 @@ namespace Graphics { struct Surface; }
namespace Sci {
-static void flushEvents(EventManager *eventMan) {
- // Flushing all the keyboard and mouse events out of the event manager
- // keeps events queued from before the start of playback from accidentally
- // activating a video stop flag
- for (;;) {
- const SciEvent event = eventMan->getSciEvent(SCI_EVENT_ANY & ~SCI_EVENT_QUIT);
- if (event.type == SCI_EVENT_NONE) {
- break;
- }
- }
-}
-
bool VideoPlayer::open(const Common::String &fileName) {
if (!_decoder->loadFile(fileName)) {
warning("Failed to load %s", fileName.c_str());
@@ -129,7 +117,10 @@ bool VideoPlayer::endHQVideo() {
}
VideoPlayer::EventFlags VideoPlayer::playUntilEvent(const EventFlags flags, const uint32 maxSleepMs) {
- flushEvents(_eventMan);
+ // Flushing all the keyboard and mouse events out of the event manager
+ // keeps events queued from before the start of playback from accidentally
+ // activating a video stop flag
+ _eventMan->flushEvents();
_decoder->start();
EventFlags stopFlag = kEventFlagNone;