Add default-monitor-time-sec
[platform/upstream/pulseaudio.git] / src / pulsecore / srbchannel.h
1 #ifndef foopulsesrbchannelhfoo
2 #define foopulsesrbchannelhfoo
3
4 /***
5   This file is part of PulseAudio.
6
7   Copyright 2014 David Henningsson, Canonical Ltd.
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, see <http://www.gnu.org/licenses/>.
21 ***/
22
23 #include <pulse/mainloop-api.h>
24 #include <pulsecore/fdsem.h>
25 #include <pulsecore/memblock.h>
26
27 /* An shm ringbuffer that is used for low overhead server-client communication.
28  * Signaling is done through eventfd semaphores (pa_fdsem). */
29
30 typedef struct pa_srbchannel pa_srbchannel;
31
32 typedef struct pa_srbchannel_template {
33     int readfd, writefd;
34     pa_memblock *memblock;
35 } pa_srbchannel_template;
36
37 pa_srbchannel* pa_srbchannel_new(pa_mainloop_api *m, pa_mempool *p);
38 /* Note: this creates a srbchannel with swapped read and write. */
39 pa_srbchannel* pa_srbchannel_new_from_template(pa_mainloop_api *m, pa_srbchannel_template *t);
40
41 void pa_srbchannel_free(pa_srbchannel *sr);
42
43 void pa_srbchannel_export(pa_srbchannel *sr, pa_srbchannel_template *t);
44
45 size_t pa_srbchannel_write(pa_srbchannel *sr, const void *data, size_t l);
46 size_t pa_srbchannel_read(pa_srbchannel *sr, void *data, size_t l);
47
48 /* Set the callback function that is called whenever data becomes available for reading.
49  * It can also be called if the output buffer was full and can now be written to.
50  *
51  * Return false to abort all processing (e g if the srbchannel has been freed during the callback).
52  * Otherwise return true.
53 */
54 typedef bool (*pa_srbchannel_cb_t)(pa_srbchannel *sr, void *userdata);
55 void pa_srbchannel_set_callback(pa_srbchannel *sr, pa_srbchannel_cb_t callback, void *userdata);
56
57 #endif