# HG changeset patch # User Ryan C. Gordon # Date 1006749230 0 # Node ID 87b00f02371047bd364bba3c652878ea7661175f # Parent 82acaa7107c277552b8ea23c899162e38d5bc6bd Added --predecode functionality. diff -r 82acaa7107c2 -r 87b00f023710 playsound/playsound.c --- a/playsound/playsound.c Mon Nov 26 04:33:31 2001 +0000 +++ b/playsound/playsound.c Mon Nov 26 04:33:50 2001 +0000 @@ -166,6 +166,7 @@ " --channels n Playback on n channels (1 or 2).\n" " --version Display version information and exit.\n" " --decoders List supported sound formats and exit.\n" + " --predecode Decode entire sample before playback.\n" " --help Display this information and exit.\n" "\n" " Valid arguments to the --format option are:\n" @@ -204,9 +205,13 @@ SDL_AudioSpec sdl_desired; SDL_AudioSpec sdl_actual; Sound_Sample *sample; + int predecode = 0; int use_specific_audiofmt = 0; int i; + setbuf(stdout, NULL); + setbuf(stderr, NULL); + /* !!! FIXME: Move this to a parse_cmdline() function... */ if (argc < 2) { @@ -284,6 +289,11 @@ return(0); } /* else if */ + else if (strcmp(argv[i], "--predecode") == 0) + { + predecode = 1; + } /* else if */ + else { fprintf(stderr, "unknown option: \"%s\"\n", argv[i]); @@ -375,6 +385,25 @@ printf("Now playing [%s]...\n", argv[i]); + if (predecode) + { + printf(" predecoding...", argv[i]); + decoded_bytes = Sound_DecodeAll(sample); + decoded_ptr = sample->buffer; + if (sample->flags & SOUND_SAMPLEFLAG_ERROR) + { + fprintf(stderr, + "Couldn't fully decode \"%s\"!\n" + " reason: [%s].\n", + " (playing first %lu bytes of decoded data...)\n", + argv[i], Sound_GetError(), decoded_bytes); + } /* if */ + else + { + printf("done.\n"); + } /* else */ + } /* if */ + done_flag = 0; SDL_PauseAudio(0); while (!done_flag)