Mercurial > SDL_sound_CoreAudio
diff playsound/playsound.c @ 168:87b00f023710
Added --predecode functionality.
author | Ryan C. Gordon <icculus@icculus.org> |
---|---|
date | Mon, 26 Nov 2001 04:33:50 +0000 |
parents | 033afe96afbc |
children | 69922f6a5c74 |
line wrap: on
line diff
--- 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)