test/loopwave.c
changeset 8354 c086e9e73916
parent 5535 96594ac5fd1a
child 8377 3a7e8110201e
     1.1 --- a/test/loopwave.c	Thu Nov 22 22:34:50 2012 -0500
     1.2 +++ b/test/loopwave.c	Thu Nov 22 22:35:38 2012 -0500
     1.3 @@ -78,18 +78,22 @@
     1.4  int
     1.5  main(int argc, char *argv[])
     1.6  {
     1.7 +    char filename[4096];
     1.8 +
     1.9      /* Load the SDL library */
    1.10      if (SDL_Init(SDL_INIT_AUDIO) < 0) {
    1.11          fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
    1.12          return (1);
    1.13      }
    1.14  
    1.15 -    if (argv[1] == NULL) {
    1.16 -        argv[1] = "sample.wav";
    1.17 +    if (argc >= 1) {
    1.18 +        SDL_strlcpy(filename, argv[1], sizeof(filename));
    1.19 +    } else {
    1.20 +        SDL_strlcpy(filename, "sample.wav", sizeof(filename));
    1.21      }
    1.22      /* Load the wave file into memory */
    1.23 -    if (SDL_LoadWAV(argv[1], &wave.spec, &wave.sound, &wave.soundlen) == NULL) {
    1.24 -        fprintf(stderr, "Couldn't load %s: %s\n", argv[1], SDL_GetError());
    1.25 +    if (SDL_LoadWAV(filename, &wave.spec, &wave.sound, &wave.soundlen) == NULL) {
    1.26 +        fprintf(stderr, "Couldn't load %s: %s\n", filename, SDL_GetError());
    1.27          quit(1);
    1.28      }
    1.29