[Scummvm-git-logs] scummvm master -> ac5a98bec9b380a34ec887d4e02bc50a3dbc8a0b
mikrosk
noreply at scummvm.org
Wed Sep 30 11:28:56 UTC 2026
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://api.github.com/repos/scummvm/scummvm .
Summary:
ac5a98bec9 BACKENDS: Add fallback for SDL_AddTimer()
Commit: ac5a98bec9b380a34ec887d4e02bc50a3dbc8a0b
https://github.com/scummvm/scummvm/commit/ac5a98bec9b380a34ec887d4e02bc50a3dbc8a0b
Author: Miro Kropacek (miro.kropacek at gmail.com)
Date: 2026-09-30T21:28:25+10:00
Commit Message:
BACKENDS: Add fallback for SDL_AddTimer()
Not every SDL 1.2 build has threading support and SDL_AddTimer() fails
exactly on such builds. Use SDL_SetTimer as a fallback.
Changed paths:
backends/timer/sdl/sdl-timer.cpp
diff --git a/backends/timer/sdl/sdl-timer.cpp b/backends/timer/sdl/sdl-timer.cpp
index cda5923c3a7..5bbaff55caf 100644
--- a/backends/timer/sdl/sdl-timer.cpp
+++ b/backends/timer/sdl/sdl-timer.cpp
@@ -38,6 +38,15 @@ static Uint32 timer_handler(Uint32 interval, void *param) {
((DefaultTimerManager *)param)->handler();
return interval;
}
+
+#if !SDL_VERSION_ATLEAST(2, 0, 0)
+static DefaultTimerManager *s_singleTimerManager = nullptr;
+
+static Uint32 single_timer_handler(Uint32 interval) {
+ s_singleTimerManager->handler();
+ return interval;
+}
+#endif
#endif
SdlTimerManager::SdlTimerManager() {
@@ -50,10 +59,26 @@ SdlTimerManager::SdlTimerManager() {
// Creates the timer callback
_timerID = SDL_AddTimer(10, &timer_handler, this);
+
+#if !SDL_VERSION_ATLEAST(2, 0, 0)
+ // SDL 1.2 built without thread support cannot create multiple
+ // timers but still provides the single legacy timer.
+ if (!_timerID) {
+ s_singleTimerManager = this;
+ if (SDL_SetTimer(10, &single_timer_handler) == -1)
+ error("Could not create SDL timer: %s", SDL_GetError());
+ }
+#endif
}
SdlTimerManager::~SdlTimerManager() {
// Removes the timer callback
+#if !SDL_VERSION_ATLEAST(2, 0, 0)
+ if (!_timerID) {
+ SDL_SetTimer(0, nullptr);
+ s_singleTimerManager = nullptr;
+ } else
+#endif
SDL_RemoveTimer(_timerID);
#if !SDL_VERSION_ATLEAST(3, 0, 0)
More information about the Scummvm-git-logs
mailing list