This repository has been archived by the owner on Feb 11, 2021. It is now read-only.
/
SDL_systimer.c
100 lines (83 loc) · 2.06 KB
1
2
/*
SDL - Simple DirectMedia Layer
3
Copyright (C) 1997-2010 Sam Lantinga
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
22
#include "SDL_config.h"
23
24
25
#if defined(SDL_TIMER_DUMMY) || defined(SDL_TIMERS_DISABLED)
26
27
28
#include "SDL_timer.h"
#include "../SDL_timer_c.h"
29
30
void
SDL_StartTicks(void)
31
32
33
{
}
34
35
Uint32
SDL_GetTicks(void)
36
{
37
38
SDL_Unsupported();
return 0;
39
40
}
41
42
void
SDL_Delay(Uint32 ms)
43
{
44
SDL_Unsupported();
45
46
47
48
49
50
51
52
}
#include "SDL_thread.h"
/* Data to handle a single periodic alarm */
static int timer_alive = 0;
static SDL_Thread *timer = NULL;
53
54
static int
RunTimer(void *unused)
55
{
56
57
58
59
60
61
62
while (timer_alive) {
if (SDL_timer_running) {
SDL_ThreadedTimerCheck();
}
SDL_Delay(1);
}
return (0);
63
64
65
}
/* This is only called if the event thread is not running */
66
67
int
SDL_SYS_TimerInit(void)
68
{
69
70
71
72
73
timer_alive = 1;
timer = SDL_CreateThread(RunTimer, NULL);
if (timer == NULL)
return (-1);
return (SDL_SetTimerThreaded(1));
74
75
}
76
77
void
SDL_SYS_TimerQuit(void)
78
{
79
80
81
82
83
timer_alive = 0;
if (timer) {
SDL_WaitThread(timer, NULL);
timer = NULL;
}
84
85
}
86
87
int
SDL_SYS_StartTimer(void)
88
{
89
90
SDL_SetError("Internal logic error: threaded timer in use");
return (-1);
91
92
}
93
94
void
SDL_SYS_StopTimer(void)
95
{
96
return;
97
}
98
99
#endif /* SDL_TIMER_DUMMY || SDL_TIMERS_DISABLED */
100
/* vi: set ts=4 sw=4 expandtab: */