test/loopwave.c
branchSDL-1.3
changeset 1668 4da1ee79c9af
parent 1662 782fd950bd46
     1.1 --- a/test/loopwave.c	Mon May 29 03:53:21 2006 +0000
     1.2 +++ b/test/loopwave.c	Mon May 29 04:04:35 2006 +0000
     1.3 @@ -27,15 +27,15 @@
     1.4  
     1.5  /* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */
     1.6  static void
     1.7 -quit (int rc)
     1.8 +quit(int rc)
     1.9  {
    1.10 -    SDL_Quit ();
    1.11 -    exit (rc);
    1.12 +    SDL_Quit();
    1.13 +    exit(rc);
    1.14  }
    1.15  
    1.16  
    1.17  void SDLCALL
    1.18 -fillerup (void *unused, Uint8 * stream, int len)
    1.19 +fillerup(void *unused, Uint8 * stream, int len)
    1.20  {
    1.21      Uint8 *waveptr;
    1.22      int waveleft;
    1.23 @@ -46,88 +46,87 @@
    1.24  
    1.25      /* Go! */
    1.26      while (waveleft <= len) {
    1.27 -        SDL_MixAudio (stream, waveptr, waveleft, SDL_MIX_MAXVOLUME);
    1.28 +        SDL_MixAudio(stream, waveptr, waveleft, SDL_MIX_MAXVOLUME);
    1.29          stream += waveleft;
    1.30          len -= waveleft;
    1.31          waveptr = wave.sound;
    1.32          waveleft = wave.soundlen;
    1.33          wave.soundpos = 0;
    1.34      }
    1.35 -    SDL_MixAudio (stream, waveptr, len, SDL_MIX_MAXVOLUME);
    1.36 +    SDL_MixAudio(stream, waveptr, len, SDL_MIX_MAXVOLUME);
    1.37      wave.soundpos += len;
    1.38  }
    1.39  
    1.40  static int done = 0;
    1.41  void
    1.42 -poked (int sig)
    1.43 +poked(int sig)
    1.44  {
    1.45      done = 1;
    1.46  }
    1.47  
    1.48  int
    1.49 -main (int argc, char *argv[])
    1.50 +main(int argc, char *argv[])
    1.51  {
    1.52      int i, n;
    1.53  
    1.54      /* Print available audio drivers */
    1.55 -    n = SDL_GetNumAudioDrivers ();
    1.56 +    n = SDL_GetNumAudioDrivers();
    1.57      if (n == 0) {
    1.58 -        printf ("No built-in audio drivers\n");
    1.59 +        printf("No built-in audio drivers\n");
    1.60      } else {
    1.61 -        printf ("Built-in audio drivers:");
    1.62 +        printf("Built-in audio drivers:");
    1.63          for (i = 0; i < n; ++i) {
    1.64              if (i > 0) {
    1.65 -                printf (",");
    1.66 +                printf(",");
    1.67              }
    1.68 -            printf (" %s", SDL_GetAudioDriver (i));
    1.69 +            printf(" %s", SDL_GetAudioDriver(i));
    1.70          }
    1.71 -        printf ("\n");
    1.72 +        printf("\n");
    1.73      }
    1.74  
    1.75      /* Load the SDL library */
    1.76 -    if (SDL_Init (SDL_INIT_AUDIO) < 0) {
    1.77 -        fprintf (stderr, "Couldn't initialize SDL: %s\n", SDL_GetError ());
    1.78 +    if (SDL_Init(SDL_INIT_AUDIO) < 0) {
    1.79 +        fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
    1.80          return (1);
    1.81      }
    1.82      if (argv[1] == NULL) {
    1.83          argv[1] = "sample.wav";
    1.84      }
    1.85      /* Load the wave file into memory */
    1.86 -    if (SDL_LoadWAV (argv[1],
    1.87 -                     &wave.spec, &wave.sound, &wave.soundlen) == NULL) {
    1.88 -        fprintf (stderr, "Couldn't load %s: %s\n", argv[1], SDL_GetError ());
    1.89 -        quit (1);
    1.90 +    if (SDL_LoadWAV(argv[1], &wave.spec, &wave.sound, &wave.soundlen) == NULL) {
    1.91 +        fprintf(stderr, "Couldn't load %s: %s\n", argv[1], SDL_GetError());
    1.92 +        quit(1);
    1.93      }
    1.94  
    1.95      wave.spec.callback = fillerup;
    1.96  #if HAVE_SIGNAL_H
    1.97      /* Set the signals */
    1.98  #ifdef SIGHUP
    1.99 -    signal (SIGHUP, poked);
   1.100 +    signal(SIGHUP, poked);
   1.101  #endif
   1.102 -    signal (SIGINT, poked);
   1.103 +    signal(SIGINT, poked);
   1.104  #ifdef SIGQUIT
   1.105 -    signal (SIGQUIT, poked);
   1.106 +    signal(SIGQUIT, poked);
   1.107  #endif
   1.108 -    signal (SIGTERM, poked);
   1.109 +    signal(SIGTERM, poked);
   1.110  #endif /* HAVE_SIGNAL_H */
   1.111  
   1.112      /* Initialize fillerup() variables */
   1.113 -    if (SDL_OpenAudio (&wave.spec, NULL) < 0) {
   1.114 -        fprintf (stderr, "Couldn't open audio: %s\n", SDL_GetError ());
   1.115 -        SDL_FreeWAV (wave.sound);
   1.116 -        quit (2);
   1.117 +    if (SDL_OpenAudio(&wave.spec, NULL) < 0) {
   1.118 +        fprintf(stderr, "Couldn't open audio: %s\n", SDL_GetError());
   1.119 +        SDL_FreeWAV(wave.sound);
   1.120 +        quit(2);
   1.121      }
   1.122 -    SDL_PauseAudio (0);
   1.123 +    SDL_PauseAudio(0);
   1.124  
   1.125      /* Let the audio run */
   1.126 -    printf ("Using audio driver: %s\n", SDL_GetCurrentAudioDriver ());
   1.127 -    while (!done && (SDL_GetAudioStatus () == SDL_AUDIO_PLAYING))
   1.128 -        SDL_Delay (1000);
   1.129 +    printf("Using audio driver: %s\n", SDL_GetCurrentAudioDriver());
   1.130 +    while (!done && (SDL_GetAudioStatus() == SDL_AUDIO_PLAYING))
   1.131 +        SDL_Delay(1000);
   1.132  
   1.133      /* Clean up on signal */
   1.134 -    SDL_CloseAudio ();
   1.135 -    SDL_FreeWAV (wave.sound);
   1.136 -    SDL_Quit ();
   1.137 +    SDL_CloseAudio();
   1.138 +    SDL_FreeWAV(wave.sound);
   1.139 +    SDL_Quit();
   1.140      return (0);
   1.141  }