src/timer/dummy/SDL_systimer.c
author Sam Lantinga
Sun, 28 May 2006 13:04:16 +0000
branchSDL-1.3
changeset 1662 782fd950bd46
parent 1635 92947e3a18db
child 1668 4da1ee79c9af
permissions -rw-r--r--
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.

WARNING: None of the video drivers have been updated for the new API yet! The API is still under design and very fluid.

The code is now run through a consistent indent format:
indent -i4 -nut -nsc -br -ce

The headers are being converted to automatically generate doxygen documentation.
     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 #if defined(SDL_TIMER_DUMMY) || defined(SDL_TIMERS_DISABLED)
    25 
    26 #include "SDL_timer.h"
    27 #include "../SDL_timer_c.h"
    28 
    29 void
    30 SDL_StartTicks (void)
    31 {
    32 }
    33 
    34 Uint32
    35 SDL_GetTicks (void)
    36 {
    37     SDL_Unsupported ();
    38     return 0;
    39 }
    40 
    41 void
    42 SDL_Delay (Uint32 ms)
    43 {
    44     SDL_Unsupported ();
    45 }
    46 
    47 #include "SDL_thread.h"
    48 
    49 /* Data to handle a single periodic alarm */
    50 static int timer_alive = 0;
    51 static SDL_Thread *timer = NULL;
    52 
    53 static int
    54 RunTimer (void *unused)
    55 {
    56     while (timer_alive) {
    57         if (SDL_timer_running) {
    58             SDL_ThreadedTimerCheck ();
    59         }
    60         SDL_Delay (1);
    61     }
    62     return (0);
    63 }
    64 
    65 /* This is only called if the event thread is not running */
    66 int
    67 SDL_SYS_TimerInit (void)
    68 {
    69     timer_alive = 1;
    70     timer = SDL_CreateThread (RunTimer, NULL);
    71     if (timer == NULL)
    72         return (-1);
    73     return (SDL_SetTimerThreaded (1));
    74 }
    75 
    76 void
    77 SDL_SYS_TimerQuit (void)
    78 {
    79     timer_alive = 0;
    80     if (timer) {
    81         SDL_WaitThread (timer, NULL);
    82         timer = NULL;
    83     }
    84 }
    85 
    86 int
    87 SDL_SYS_StartTimer (void)
    88 {
    89     SDL_SetError ("Internal logic error: threaded timer in use");
    90     return (-1);
    91 }
    92 
    93 void
    94 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: */