From 9e21182e018db8755dea6368eed93a1a2b93f6f7 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 14 Aug 2009 04:18:23 +0200 Subject: thread-mq: never drop queued messages for the main loop Previously we might have dropped messages from IO trheads to the main thread. This tuend out to be problematic since this cause SHM release messages to be lost. More visibly however this could cause playback freezing when moving streams between sinks and removing the old sink right away. --- src/pulsecore/thread-mq.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/pulsecore/thread-mq.c') diff --git a/src/pulsecore/thread-mq.c b/src/pulsecore/thread-mq.c index 34f92a7e..ec67ae87 100644 --- a/src/pulsecore/thread-mq.c +++ b/src/pulsecore/thread-mq.c @@ -104,6 +104,13 @@ void pa_thread_mq_init(pa_thread_mq *q, pa_mainloop_api *mainloop, pa_rtpoll *rt void pa_thread_mq_done(pa_thread_mq *q) { pa_assert(q); + /* Since we are called from main context we can be sure that the + * inq is empty. However, the outq might still contain messages + * for the main loop, which we need to dispatch (e.g. release + * msgs, other stuff). Hence do so. */ + + pa_asyncmsgq_flush(q->outq, TRUE); + q->mainloop->io_free(q->read_event); q->mainloop->io_free(q->write_event); q->read_event = q->write_event = NULL; -- cgit From 011add1c838f65e87a7abaec2792f510d3b0bb20 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Sat, 15 Aug 2009 22:23:42 +0200 Subject: thread-mq: do final q flush only when we aren't dispatching anyway --- src/pulsecore/thread-mq.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/pulsecore/thread-mq.c') diff --git a/src/pulsecore/thread-mq.c b/src/pulsecore/thread-mq.c index ec67ae87..73997a74 100644 --- a/src/pulsecore/thread-mq.c +++ b/src/pulsecore/thread-mq.c @@ -59,7 +59,7 @@ static void asyncmsgq_read_cb(pa_mainloop_api*api, pa_io_event* e, int fd, pa_io pa_memchunk chunk; /* Check whether there is a message for us to process */ - while (pa_asyncmsgq_get(aq, &object, &code, &data, &offset, &chunk, 0) == 0) { + while (pa_asyncmsgq_get(aq, &object, &code, &data, &offset, &chunk, 0) >= 0) { int ret; ret = pa_asyncmsgq_dispatch(object, code, data, offset, &chunk); @@ -107,9 +107,11 @@ void pa_thread_mq_done(pa_thread_mq *q) { /* Since we are called from main context we can be sure that the * inq is empty. However, the outq might still contain messages * for the main loop, which we need to dispatch (e.g. release - * msgs, other stuff). Hence do so. */ + * msgs, other stuff). Hence do so if we aren't currently + * dispatching anyway. */ - pa_asyncmsgq_flush(q->outq, TRUE); + if (!pa_asyncmsgq_dispatching(q->outq)) + pa_asyncmsgq_flush(q->outq, TRUE); q->mainloop->io_free(q->read_event); q->mainloop->io_free(q->write_event); -- cgit