]> code.delx.au - pulseaudio/blob - src/pulsecore/asyncmsgq.h
remap: Make resampler's remap structure more self-contained
[pulseaudio] / src / pulsecore / asyncmsgq.h
1 #ifndef foopulseasyncmsgqhfoo
2 #define foopulseasyncmsgqhfoo
3
4 /***
5 This file is part of PulseAudio.
6
7 Copyright 2004-2006 Lennart Poettering
8
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.
13
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.
18
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 ***/
24
25 #include <sys/types.h>
26
27 #include <pulsecore/asyncq.h>
28 #include <pulsecore/memchunk.h>
29 #include <pulsecore/msgobject.h>
30
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.
38 *
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)
44 *
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. */
48
49 enum {
50 PA_MESSAGE_SHUTDOWN = -1/* A generic message to inform the handler of this queue to quit */
51 };
52
53 typedef struct pa_asyncmsgq pa_asyncmsgq;
54
55 pa_asyncmsgq* pa_asyncmsgq_new(unsigned size);
56 pa_asyncmsgq* pa_asyncmsgq_ref(pa_asyncmsgq *q);
57
58 void pa_asyncmsgq_unref(pa_asyncmsgq* q);
59
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);
62
63 int pa_asyncmsgq_get(pa_asyncmsgq *q, pa_msgobject **object, int *code, void **userdata, int64_t *offset, pa_memchunk *memchunk, bool 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);
68
69 void pa_asyncmsgq_flush(pa_asyncmsgq *a, bool run);
70
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);
75
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);
80
81 bool pa_asyncmsgq_dispatching(pa_asyncmsgq *a);
82
83 #endif