]> code.delx.au - pulseaudio/blob - src/pulsecore/asyncq.h
remap: Change remapping function argument type from void to int16_t / float as approp...
[pulseaudio] / src / pulsecore / asyncq.h
1 #ifndef foopulseasyncqhfoo
2 #define foopulseasyncqhfoo
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 #include <pulse/def.h>
27 #include <pulsecore/macro.h>
28
29 /* A simple, asynchronous, lock-free (if requested also wait-free)
30 * queue. Not multiple-reader/multiple-writer safe. If that is
31 * required both sides can be protected by a mutex each. --- Which is
32 * not a bad thing in most cases, since this queue is intended for
33 * communication between a normal thread and a single real-time
34 * thread. Only the real-time side needs to be lock-free/wait-free.
35 *
36 * If the queue is full and another entry shall be pushed, or when the
37 * queue is empty and another entry shall be popped and the "wait"
38 * argument is non-zero, the queue will block on a UNIX FIFO object --
39 * that will probably require locking on the kernel side -- which
40 * however is probably not problematic, because we do it only on
41 * starvation or overload in which case we have to block anyway. */
42
43 typedef struct pa_asyncq pa_asyncq;
44
45 pa_asyncq* pa_asyncq_new(unsigned size);
46 void pa_asyncq_free(pa_asyncq* q, pa_free_cb_t free_cb);
47
48 void* pa_asyncq_pop(pa_asyncq *q, bool wait);
49 int pa_asyncq_push(pa_asyncq *q, void *p, bool wait);
50
51 /* Similar to pa_asyncq_push(), but if the queue is full, postpone the
52 * appending of the item locally and delay until
53 * pa_asyncq_before_poll_post() is called. */
54 void pa_asyncq_post(pa_asyncq*l, void *p);
55
56 /* For the reading side */
57 int pa_asyncq_read_fd(pa_asyncq *q);
58 int pa_asyncq_read_before_poll(pa_asyncq *a);
59 void pa_asyncq_read_after_poll(pa_asyncq *a);
60
61 /* For the writing side */
62 int pa_asyncq_write_fd(pa_asyncq *q);
63 void pa_asyncq_write_before_poll(pa_asyncq *a);
64 void pa_asyncq_write_after_poll(pa_asyncq *a);
65
66 #endif