ref: 859d5c9146a31c65c538ce799ed3eccd30e1e78d
parent: 753f64a8777aac7341193ba6f17efca677509827
author: cinap_lenrek <[email protected]>
date: Thu Nov 16 09:15:00 EST 2017
audio/flacdec: add eof handler avoiding endless spinning on broken files (thanks deuteron)
--- a/sys/src/cmd/audio/flacdec/flacdec.c
+++ b/sys/src/cmd/audio/flacdec/flacdec.c
@@ -119,6 +119,12 @@
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;
@@ -125,7 +131,7 @@
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;