summaryrefslogtreecommitdiff
path: root/sys/src/cmd/audio
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@felloff.net>2017-11-16 14:15:00 +0100
committercinap_lenrek <cinap_lenrek@felloff.net>2017-11-16 14:15:00 +0100
commit859d5c9146a31c65c538ce799ed3eccd30e1e78d (patch)
tree08fb42cd0df7caf27361b3628156064f223e05f3 /sys/src/cmd/audio
parent753f64a8777aac7341193ba6f17efca677509827 (diff)
audio/flacdec: add eof handler avoiding endless spinning on broken files (thanks deuteron)
Diffstat (limited to 'sys/src/cmd/audio')
-rw-r--r--sys/src/cmd/audio/flacdec/flacdec.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/sys/src/cmd/audio/flacdec/flacdec.c b/sys/src/cmd/audio/flacdec/flacdec.c
index 1b0f2fd3b..d8bc50a35 100644
--- a/sys/src/cmd/audio/flacdec/flacdec.c
+++ b/sys/src/cmd/audio/flacdec/flacdec.c
@@ -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;