test/testtimer.c
branchSDL-1.3
changeset 1668 4da1ee79c9af
parent 1662 782fd950bd46
     1.1 --- a/test/testtimer.c	Mon May 29 03:53:21 2006 +0000
     1.2 +++ b/test/testtimer.c	Mon May 29 04:04:35 2006 +0000
     1.3 @@ -13,78 +13,78 @@
     1.4  static int ticks = 0;
     1.5  
     1.6  static Uint32 SDLCALL
     1.7 -ticktock (Uint32 interval)
     1.8 +ticktock(Uint32 interval)
     1.9  {
    1.10      ++ticks;
    1.11      return (interval);
    1.12  }
    1.13  
    1.14  static Uint32 SDLCALL
    1.15 -callback (Uint32 interval, void *param)
    1.16 +callback(Uint32 interval, void *param)
    1.17  {
    1.18 -    printf ("Timer %d : param = %d\n", interval, (int) (uintptr_t) param);
    1.19 +    printf("Timer %d : param = %d\n", interval, (int) (uintptr_t) param);
    1.20      return interval;
    1.21  }
    1.22  
    1.23  int
    1.24 -main (int argc, char *argv[])
    1.25 +main(int argc, char *argv[])
    1.26  {
    1.27      int desired;
    1.28      SDL_TimerID t1, t2, t3;
    1.29  
    1.30 -    if (SDL_Init (SDL_INIT_TIMER) < 0) {
    1.31 -        fprintf (stderr, "Couldn't initialize SDL: %s\n", SDL_GetError ());
    1.32 +    if (SDL_Init(SDL_INIT_TIMER) < 0) {
    1.33 +        fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
    1.34          return (1);
    1.35      }
    1.36  
    1.37      /* Start the timer */
    1.38      desired = 0;
    1.39      if (argv[1]) {
    1.40 -        desired = atoi (argv[1]);
    1.41 +        desired = atoi(argv[1]);
    1.42      }
    1.43      if (desired == 0) {
    1.44          desired = DEFAULT_RESOLUTION;
    1.45      }
    1.46 -    SDL_SetTimer (desired, ticktock);
    1.47 +    SDL_SetTimer(desired, ticktock);
    1.48  
    1.49      /* Wait 10 seconds */
    1.50 -    printf ("Waiting 10 seconds\n");
    1.51 -    SDL_Delay (10 * 1000);
    1.52 +    printf("Waiting 10 seconds\n");
    1.53 +    SDL_Delay(10 * 1000);
    1.54  
    1.55      /* Stop the timer */
    1.56 -    SDL_SetTimer (0, NULL);
    1.57 +    SDL_SetTimer(0, NULL);
    1.58  
    1.59      /* Print the results */
    1.60      if (ticks) {
    1.61 -        fprintf (stderr,
    1.62 -                 "Timer resolution: desired = %d ms, actual = %f ms\n",
    1.63 -                 desired, (double) (10 * 1000) / ticks);
    1.64 +        fprintf(stderr,
    1.65 +                "Timer resolution: desired = %d ms, actual = %f ms\n",
    1.66 +                desired, (double) (10 * 1000) / ticks);
    1.67      }
    1.68  
    1.69      /* Test multiple timers */
    1.70 -    printf ("Testing multiple timers...\n");
    1.71 -    t1 = SDL_AddTimer (100, callback, (void *) 1);
    1.72 +    printf("Testing multiple timers...\n");
    1.73 +    t1 = SDL_AddTimer(100, callback, (void *) 1);
    1.74      if (!t1)
    1.75 -        fprintf (stderr, "Could not create timer 1: %s\n", SDL_GetError ());
    1.76 -    t2 = SDL_AddTimer (50, callback, (void *) 2);
    1.77 +        fprintf(stderr, "Could not create timer 1: %s\n", SDL_GetError());
    1.78 +    t2 = SDL_AddTimer(50, callback, (void *) 2);
    1.79      if (!t2)
    1.80 -        fprintf (stderr, "Could not create timer 2: %s\n", SDL_GetError ());
    1.81 -    t3 = SDL_AddTimer (233, callback, (void *) 3);
    1.82 +        fprintf(stderr, "Could not create timer 2: %s\n", SDL_GetError());
    1.83 +    t3 = SDL_AddTimer(233, callback, (void *) 3);
    1.84      if (!t3)
    1.85 -        fprintf (stderr, "Could not create timer 3: %s\n", SDL_GetError ());
    1.86 +        fprintf(stderr, "Could not create timer 3: %s\n", SDL_GetError());
    1.87  
    1.88      /* Wait 10 seconds */
    1.89 -    printf ("Waiting 10 seconds\n");
    1.90 -    SDL_Delay (10 * 1000);
    1.91 +    printf("Waiting 10 seconds\n");
    1.92 +    SDL_Delay(10 * 1000);
    1.93  
    1.94 -    printf ("Removing timer 1 and waiting 5 more seconds\n");
    1.95 -    SDL_RemoveTimer (t1);
    1.96 +    printf("Removing timer 1 and waiting 5 more seconds\n");
    1.97 +    SDL_RemoveTimer(t1);
    1.98  
    1.99 -    SDL_Delay (5 * 1000);
   1.100 +    SDL_Delay(5 * 1000);
   1.101  
   1.102 -    SDL_RemoveTimer (t2);
   1.103 -    SDL_RemoveTimer (t3);
   1.104 +    SDL_RemoveTimer(t2);
   1.105 +    SDL_RemoveTimer(t3);
   1.106  
   1.107 -    SDL_Quit ();
   1.108 +    SDL_Quit();
   1.109      return (0);
   1.110  }