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
This commit is contained in:
Lennart Poettering 2006-07-29 15:02:24 +00:00
parent d1db037577
commit b325e07c73

View 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);