From b325e07c7337a533792aac2d19ac6ff364c92fb6 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Sat, 29 Jul 2006 15:02:24 +0000 Subject: handle EOF correctly if it is read before the stream was created git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@1164 fefdeb5f-60dc-0310-8127-8f9354f1896f --- src/utils/pacat.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'src/utils/pacat.c') diff --git a/src/utils/pacat.c b/src/utils/pacat.c index 10edd71d..dda5c192 100644 --- a/src/utils/pacat.c +++ b/src/utils/pacat.c @@ -291,18 +291,22 @@ static void stdin_callback(pa_mainloop_api*a, pa_io_event *e, int fd, pa_io_even if ((r = read(fd, buffer, l)) <= 0) { if (r == 0) { - pa_operation *o; - if (verbose) fprintf(stderr, "Got EOF.\n"); - - if (!(o = pa_stream_drain(stream, stream_drain_complete, NULL))) { - fprintf(stderr, "pa_stream_drain(): %s\n", pa_strerror(pa_context_errno(context))); - quit(1); - return; - } - pa_operation_unref(o); + if (stream) { + pa_operation *o; + + if (!(o = pa_stream_drain(stream, stream_drain_complete, NULL))) { + fprintf(stderr, "pa_stream_drain(): %s\n", pa_strerror(pa_context_errno(context))); + quit(1); + return; + } + + pa_operation_unref(o); + } else + quit(0); + } else { fprintf(stderr, "read() failed: %s\n", strerror(errno)); quit(1); -- cgit