audio/flacdec: add eof handler avoiding endless spinning on broken files (thanks deuteron)
This commit is contained in:
parent
753f64a877
commit
859d5c9146
1 changed files with 7 additions and 1 deletions
|
@ -119,13 +119,19 @@ decerror(FLAC__StreamDecoder *dec, FLAC__StreamDecoderErrorStatus status, void *
|
|||
fprintf(stderr, "decode error: %s (%d)\n", FLAC__StreamDecoderErrorStatusString[status], status);
|
||||
}
|
||||
|
||||
static FLAC__bool
|
||||
checkeof(const FLAC__StreamDecoder*, void*)
|
||||
{
|
||||
return feof(stdin);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
FLAC__bool ok = true;
|
||||
FLAC__StreamDecoder *dec = 0;
|
||||
|
||||
dec = FLAC__stream_decoder_new();
|
||||
FLAC__stream_decoder_init_stream(dec, decinput, NULL, NULL, NULL, NULL, decoutput, NULL, decerror, NULL);
|
||||
FLAC__stream_decoder_init_stream(dec, decinput, NULL, NULL, NULL, checkeof, decoutput, NULL, decerror, NULL);
|
||||
FLAC__stream_decoder_process_until_end_of_stream(dec);
|
||||
FLAC__stream_decoder_finish(dec);
|
||||
return 0;
|
||||
|
|
Loading…
Reference in a new issue