src/timer/dummy/SDL_systimer.c
author Sam Lantinga
Wed, 08 Mar 2006 08:30:17 +0000
changeset 1484 b2b476a4a73c
parent 1402 d910939febfa
child 1635 92947e3a18db
permissions -rw-r--r--
Added documentation on how to build a completely useless SDL library. :)
     1 /*
     2     SDL - Simple DirectMedia Layer
     3     Copyright (C) 1997-2006 Sam Lantinga
     4 
     5     This library is free software; you can redistribute it and/or
     6     modify it under the terms of the GNU Lesser General Public
     7     License as published by the Free Software Foundation; either
     8     version 2.1 of the License, or (at your option) any later version.
     9 
    10     This library is distributed in the hope that it will be useful,
    11     but WITHOUT ANY WARRANTY; without even the implied warranty of
    12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    13     Lesser General Public License for more details.
    14 
    15     You should have received a copy of the GNU Lesser General Public
    16     License along with this library; if not, write to the Free Software
    17     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    18 
    19     Sam Lantinga
    20     slouken@libsdl.org
    21 */
    22 #include "SDL_config.h"
    23 
    24 #include "SDL_timer.h"
    25 #include "../SDL_timer_c.h"
    26 
    27 void SDL_StartTicks(void)
    28 {
    29 }
    30 
    31 Uint32 SDL_GetTicks (void)
    32 {
    33 	SDL_Unsupported();
    34 	return 0;
    35 }
    36 
    37 void SDL_Delay (Uint32 ms)
    38 {
    39 	SDL_Unsupported();
    40 }
    41 
    42 #include "SDL_thread.h"
    43 
    44 /* Data to handle a single periodic alarm */
    45 static int timer_alive = 0;
    46 static SDL_Thread *timer = NULL;
    47 
    48 static int RunTimer(void *unused)
    49 {
    50 	while ( timer_alive ) {
    51 		if ( SDL_timer_running ) {
    52 			SDL_ThreadedTimerCheck();
    53 		}
    54 		SDL_Delay(1);
    55 	}
    56 	return(0);
    57 }
    58 
    59 /* This is only called if the event thread is not running */
    60 int SDL_SYS_TimerInit(void)
    61 {
    62 	timer_alive = 1;
    63 	timer = SDL_CreateThread(RunTimer, NULL);
    64 	if ( timer == NULL )
    65 		return(-1);
    66 	return(SDL_SetTimerThreaded(1));
    67 }
    68 
    69 void SDL_SYS_TimerQuit(void)
    70 {
    71 	timer_alive = 0;
    72 	if ( timer ) {
    73 		SDL_WaitThread(timer, NULL);
    74 		timer = NULL;
    75 	}
    76 }
    77 
    78 int SDL_SYS_StartTimer(void)
    79 {
    80 	SDL_SetError("Internal logic error: threaded timer in use");
    81 	return(-1);
    82 }
    83 
    84 void SDL_SYS_StopTimer(void)
    85 {
    86 	return;
    87 }