From cffc7768bd5b8d16308c15102b4d03d08d287098 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 9 Jul 2004 23:26:10 +0000 Subject: fix recording for simpel and esound protocols git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@54 fefdeb5f-60dc-0310-8127-8f9354f1896f --- src/simple.c | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) (limited to 'src/simple.c') diff --git a/src/simple.c b/src/simple.c index 50bfea43..ba0a8f0c 100644 --- a/src/simple.c +++ b/src/simple.c @@ -14,24 +14,37 @@ struct pa_simple { int dead, drained; }; +static int check_error(struct pa_simple *p, int *perror) { + assert(p); + + if (pa_context_is_dead(p->context) || (p->stream && pa_stream_is_dead(p->stream))) { + if (perror) + *perror = pa_context_errno(p->context); + return -1; + } + + return 0; +} + static int iterate(struct pa_simple *p, int block, int *perror) { assert(p && p->context && p->mainloop); + if (check_error(p, perror) < 0) + return -1; + if (!block && !pa_context_is_pending(p->context)) return 0; - + do { - if (pa_context_is_dead(p->context) || (p->stream && pa_stream_is_dead(p->stream))) { - if (perror) - *perror = pa_context_errno(p->context); - return -1; - } - if (pa_mainloop_iterate(p->mainloop, 1, NULL) < 0) { if (perror) *perror = PA_ERROR_INTERNAL; return -1; } + + if (check_error(p, perror) < 0) + return -1; + } while (pa_context_is_pending(p->context)); return 0; -- cgit