From 3951d0a4e5ae26d9f72a5a64d09cb7b9214b2222 Mon Sep 17 00:00:00 2001 From: Martin Storsjo Date: Fri, 7 Feb 2014 14:50:46 +0200 Subject: Allow opening stdin when "-" is specified --- wavreader.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'wavreader.c') diff --git a/wavreader.c b/wavreader.c index a8b4d0e..69b3b57 100644 --- a/wavreader.c +++ b/wavreader.c @@ -68,7 +68,10 @@ void* wav_read_open(const char *filename) { long data_pos = 0; memset(wr, 0, sizeof(*wr)); - wr->wav = fopen(filename, "rb"); + if (!strcmp(filename, "-")) + wr->wav = stdin; + else + wr->wav = fopen(filename, "rb"); if (wr->wav == NULL) { free(wr); return NULL; @@ -136,7 +139,8 @@ void* wav_read_open(const char *filename) { void wav_read_close(void* obj) { struct wav_reader* wr = (struct wav_reader*) obj; - fclose(wr->wav); + if (wr->wav != stdin) + fclose(wr->wav); free(wr); } -- cgit v1.2.3