1 #ifndef foopulseasyncmsgqhfoo
2 #define foopulseasyncmsgqhfoo
7 This file is part of PulseAudio.
9 Copyright 2004-2006 Lennart Poettering
11 PulseAudio is free software; you can redistribute it and/or modify
12 it under the terms of the GNU Lesser General Public License as
13 published by the Free Software Foundation; either version 2.1 of the
14 License, or (at your option) any later version.
16 PulseAudio is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 Lesser General Public License for more details.
21 You should have received a copy of the GNU Lesser General Public
22 License along with PulseAudio; if not, write to the Free Software
23 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
27 #include <sys/types.h>
29 #include <pulsecore/asyncq.h>
30 #include <pulsecore/memchunk.h>
31 #include <pulsecore/msgobject.h>
33 /* A simple asynchronous message queue, based on pa_asyncq. In
34 * contrast to pa_asyncq this one is multiple-writer safe, though
35 * still not multiple-reader safe. This queue is intended to be used
36 * for controlling real-time threads from normal-priority
37 * threads. Multiple-writer-safety is accomplished by using a mutex on
38 * the writer side. This queue is thus not useful for communication
39 * between several real-time threads.
41 * The queue takes messages consisting of:
42 * "Object" for which this messages is intended (may be NULL)
43 * A numeric message code
44 * Arbitrary userdata pointer (may be NULL)
45 * A memchunk (may be NULL)
47 * There are two functions for submitting messages: _post and
48 * _send. The former just enqueues the message asynchronously, the
49 * latter waits for completion, synchronously. */
52 PA_MESSAGE_SHUTDOWN = -1/* A generic message to inform the handler of this queue to quit */
55 typedef struct pa_asyncmsgq pa_asyncmsgq;
57 pa_asyncmsgq* pa_asyncmsgq_new(unsigned size);
58 pa_asyncmsgq* pa_asyncmsgq_ref(pa_asyncmsgq *q);
60 void pa_asyncmsgq_unref(pa_asyncmsgq* q);
62 void pa_asyncmsgq_post(pa_asyncmsgq *q, pa_msgobject *object, int code, const void *userdata, int64_t offset, const pa_memchunk *memchunk, pa_free_cb_t userdata_free_cb);
63 int pa_asyncmsgq_send(pa_asyncmsgq *q, pa_msgobject *object, int code, const void *userdata, int64_t offset, const pa_memchunk *memchunk);
65 int pa_asyncmsgq_get(pa_asyncmsgq *q, pa_msgobject **object, int *code, void **userdata, int64_t *offset, pa_memchunk *memchunk, pa_bool_t wait);
66 int pa_asyncmsgq_dispatch(pa_msgobject *object, int code, void *userdata, int64_t offset, pa_memchunk *memchunk);
67 void pa_asyncmsgq_done(pa_asyncmsgq *q, int ret);
68 int pa_asyncmsgq_wait_for(pa_asyncmsgq *a, int code);
69 int pa_asyncmsgq_process_one(pa_asyncmsgq *a);
71 /* For the reading side */
72 int pa_asyncmsgq_read_fd(pa_asyncmsgq *q);
73 int pa_asyncmsgq_read_before_poll(pa_asyncmsgq *a);
74 void pa_asyncmsgq_read_after_poll(pa_asyncmsgq *a);
76 /* For the write side */
77 int pa_asyncmsgq_write_fd(pa_asyncmsgq *q);
78 void pa_asyncmsgq_write_before_poll(pa_asyncmsgq *a);
79 void pa_asyncmsgq_write_after_poll(pa_asyncmsgq *a);