]> code.delx.au - pulseaudio/commitdiff
handle EOF correctly if it is read before the stream was created
authorLennart Poettering <lennart@poettering.net>
Sat, 29 Jul 2006 15:02:24 +0000 (15:02 +0000)
committerLennart Poettering <lennart@poettering.net>
Sat, 29 Jul 2006 15:02:24 +0000 (15:02 +0000)
git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@1164 fefdeb5f-60dc-0310-8127-8f9354f1896f

src/utils/pacat.c

index 10edd71d724340e1fdf1862f8d7c5b8147c31d87..dda5c192938505f0cdd5b52ee5e7a0a0ae3b8efe 100644 (file)
@@ -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);