Skip to content

Commit

Permalink
Added --predecode functionality.
Browse files Browse the repository at this point in the history
  • Loading branch information
icculus committed Nov 26, 2001
1 parent 92e234e commit 72eb9fa
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions playsound/playsound.c
Expand Up @@ -166,6 +166,7 @@ static void output_usage(const char *argv0)
" --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"
Expand Down Expand Up @@ -204,9 +205,13 @@ int main(int argc, char **argv)
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)
{
Expand Down Expand Up @@ -284,6 +289,11 @@ int main(int argc, char **argv)
return(0);
} /* else if */

else if (strcmp(argv[i], "--predecode") == 0)
{
predecode = 1;
} /* else if */

else
{
fprintf(stderr, "unknown option: \"%s\"\n", argv[i]);
Expand Down Expand Up @@ -375,6 +385,25 @@ int main(int argc, char **argv)

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)
Expand Down

0 comments on commit 72eb9fa

Please sign in to comment.