fix os2 timer in fallback mode
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
diff --git a/src/timer/os2/SDL_systimer.c b/src/timer/os2/SDL_systimer.c
index c5bcf64..8a8425d 100644
--- a/src/timer/os2/SDL_systimer.c
+++ b/src/timer/os2/SDL_systimer.c
@@ -39,6 +39,7 @@
typedef unsigned long long ULLONG;
+static SDL_bool ticks_started = SDL_FALSE;
static ULONG ulTmrFreq = 0;
static ULLONG ullTmrStart = 0;
@@ -46,7 +47,14 @@ void
SDL_TicksInit(void)
{
ULONG ulTmrStart; /* for 32-bit fallback. */
- ULONG ulRC = DosTmrQueryFreq(&ulTmrFreq);
+ ULONG ulRC;
+
+ if (ticks_started) {
+ return;
+ }
+ ticks_started = SDL_TRUE;
+
+ ulRC = DosTmrQueryFreq(&ulTmrFreq);
if (ulRC != NO_ERROR) {
debug_os2("DosTmrQueryFreq() failed, rc = %u", ulRC);
} else {
@@ -65,6 +73,7 @@ SDL_TicksInit(void)
void
SDL_TicksQuit(void)
{
+ ticks_started = SDL_FALSE;
}
Uint64
@@ -73,7 +82,7 @@ SDL_GetTicks64(void)
Uint64 ui64Result;
ULLONG ullTmrNow;
- if (ulTmrFreq == 0) { /* Was not initialized. */
+ if (!ticks_started) {
SDL_TicksInit();
}