summaryrefslogtreecommitdiffstats
path: root/src/pulsecore/thread-mq.c
diff options
context:
space:
mode:
authorDaniel Mack <daniel@caiaq.de>2009-09-14 16:25:35 +0800
committerDaniel Mack <daniel@caiaq.de>2009-09-14 16:25:35 +0800
commitbebaa491650c48697b861ec5e76816e9af1a8803 (patch)
treeb57d38476473f8fc6e282f8c39f730c936fa10d4 /src/pulsecore/thread-mq.c
parentc6d330ef91ce401660f907536b1bfd0591c14c2a (diff)
parent180ef1eebdfbdf0220af1fb5e4bf43e348207cde (diff)
Merge branch 'master' of git://0pointer.de/pulseaudio
Diffstat (limited to 'src/pulsecore/thread-mq.c')
-rw-r--r--src/pulsecore/thread-mq.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/pulsecore/thread-mq.c b/src/pulsecore/thread-mq.c
index 34f92a7e..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);
@@ -104,6 +104,15 @@ 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 if we aren't currently
+ * dispatching anyway. */
+
+ 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);
q->read_event = q->write_event = NULL;