From a39e3a70f774ed688f0cbd67a40aa4e67a0320eb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Noel?= <[EMAIL REDACTED]>
Date: Tue, 15 Sep 2026 12:26:55 +0200
Subject: [PATCH] DisplayYUVOverlay: honor AllowThreadedDraws
Currently, if SMPEG calls SDL_DisplayYUVOverlay() from a worker thread,
ie not the thread which called SDL_SetVideoMode(),
frames accumulate until the main thread eventually pumps events.
The result is a video where audio playback remains normal but only
a few video frames are visibly presented per second.
Re-use the SDL12COMPAT_ALLOW_THREADED_DRAWS hint already used by
SDL_UpdateRects(), this fixes the stuttering intro video in
LGP's "Majesty: The Fantasy Kingdom Sim"
---
src/SDL12_compat.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/SDL12_compat.c b/src/SDL12_compat.c
index 616a0ea4a..c32a77a9b 100644
--- a/src/SDL12_compat.c
+++ b/src/SDL12_compat.c
@@ -8212,7 +8212,7 @@ SDL_DisplayYUVOverlay(SDL12_Overlay *overlay12, SDL12_Rect *dstrect12)
for (overlay = QueuedDisplayOverlays.next; overlay != NULL; overlay = overlay->next) {
if (overlay->overlay12 == overlay12) { /* trying to draw the same overlay twice in one frame? Dump the current surface and overlays to the screen now. */
/* Force an update of the screen. */
- if (ThisIsSetVideoModeThread) {
+ if (ThisIsSetVideoModeThread || AllowThreadedDraws) {
if (VideoSurfaceUpdatedInBackgroundThread) {
SDL_Flip(VideoSurface12); /* this will update the texture and present. */
} else if (VideoSurfacePresentTicks) {