virtual-sink: Fix a crash when moving the sink to a new master right after setup.
[pulseaudio-raopUDP/pulseaudio-raop-alac.git] / src / pulsecore / asyncmsgq.h
blob1085c2f025b8c86c690ce3a3049910e443d989e4
1 #ifndef foopulseasyncmsgqhfoo
2 #define foopulseasyncmsgqhfoo
4 /***
5 This file is part of PulseAudio.
7 Copyright 2004-2006 Lennart Poettering
9 PulseAudio is free software; you can redistribute it and/or modify
10 it under the terms of the GNU Lesser General Public License as
11 published by the Free Software Foundation; either version 2.1 of the
12 License, or (at your option) any later version.
14 PulseAudio is distributed in the hope that it will be useful, but
15 WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 Lesser General Public License for more details.
19 You should have received a copy of the GNU Lesser General Public
20 License along with PulseAudio; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
22 USA.
23 ***/
25 #include <sys/types.h>
27 #include <pulsecore/asyncq.h>
28 #include <pulsecore/memchunk.h>
29 #include <pulsecore/msgobject.h>
31 /* A simple asynchronous message queue, based on pa_asyncq. In
32 * contrast to pa_asyncq this one is multiple-writer safe, though
33 * still not multiple-reader safe. This queue is intended to be used
34 * for controlling real-time threads from normal-priority
35 * threads. Multiple-writer-safety is accomplished by using a mutex on
36 * the writer side. This queue is thus not useful for communication
37 * between several real-time threads.
39 * The queue takes messages consisting of:
40 * "Object" for which this messages is intended (may be NULL)
41 * A numeric message code
42 * Arbitrary userdata pointer (may be NULL)
43 * A memchunk (may be NULL)
45 * There are two functions for submitting messages: _post and
46 * _send. The former just enqueues the message asynchronously, the
47 * latter waits for completion, synchronously. */
49 enum {
50 PA_MESSAGE_SHUTDOWN = -1/* A generic message to inform the handler of this queue to quit */
53 typedef struct pa_asyncmsgq pa_asyncmsgq;
55 pa_asyncmsgq* pa_asyncmsgq_new(unsigned size);
56 pa_asyncmsgq* pa_asyncmsgq_ref(pa_asyncmsgq *q);
58 void pa_asyncmsgq_unref(pa_asyncmsgq* q);
60 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);
61 int pa_asyncmsgq_send(pa_asyncmsgq *q, pa_msgobject *object, int code, const void *userdata, int64_t offset, const pa_memchunk *memchunk);
63 int pa_asyncmsgq_get(pa_asyncmsgq *q, pa_msgobject **object, int *code, void **userdata, int64_t *offset, pa_memchunk *memchunk, pa_bool_t wait);
64 int pa_asyncmsgq_dispatch(pa_msgobject *object, int code, void *userdata, int64_t offset, pa_memchunk *memchunk);
65 void pa_asyncmsgq_done(pa_asyncmsgq *q, int ret);
66 int pa_asyncmsgq_wait_for(pa_asyncmsgq *a, int code);
67 int pa_asyncmsgq_process_one(pa_asyncmsgq *a);
69 void pa_asyncmsgq_flush(pa_asyncmsgq *a, pa_bool_t run);
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);
81 pa_bool_t pa_asyncmsgq_dispatching(pa_asyncmsgq *a);
83 #endif