libsdl-org / sdl12-compat

An SDL-1.2 compatibility layer that uses SDL 2.0 behind the scenes.
Other
193 stars 40 forks source link

Call PumpEvents in PresentScreen when SDL_EVENTTHREAD enabled #281

Closed sulix closed 1 year ago

sulix commented 1 year ago

At the moment, we "emulate" SDL_EVENTTHREAD by calling SDL_PumpEvents() in SDL_PeekEvent(). But some games don't even do this, so events aren't pumped at all, particularly while (e.g.) videos are playing, which is often just a tight SDL_DisplayYUVOverlay() loop.

If we SDL_PumpEvents() from within PresentScreen(), we should at least get events as long as the screen is being updated.

The complexity here is that SDL_PumpEvents() itself calls PresentScreen() to get a minimal framerate from things rendering directly to the front buffer. So we add a quick check to avoid SDL_PumpEvents() from entering infinite recursion by calling itself.

Should fix the difficulty with skipping videos in Alpha Centauri mentioned in #278.

vv221 commented 1 year ago

This one will be a bit tricky to test, because the inability to skip video seems to happen in two distinct ways:

Neither of these bugs seems to be systematic, so I will do multiple tests with your patch and report here once I am confident that it improves the situation for either of the symptoms.

sulix commented 1 year ago

No worries. I'm pretty sure this fixes the unskippable video issue — I haven't been able to reproduce it since, and it makes sense that this could be the cause.

I never encountered the second issue, so who knows…