Add default-monitor-time-sec
[platform/upstream/pulseaudio.git] / src / pulsecore / shm.h
1 #ifndef foopulseshmhfoo
2 #define foopulseshmhfoo
3
4 /***
5   This file is part of PulseAudio.
6
7   Copyright 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, see <http://www.gnu.org/licenses/>.
21 ***/
22
23 #include <sys/types.h>
24
25 #include <pulsecore/macro.h>
26 #include <pulsecore/mem.h>
27
28 typedef struct pa_shm {
29     pa_mem_type_t type;
30     unsigned id;
31     void *ptr;
32     size_t size;
33
34     /* Only for type = PA_MEM_TYPE_SHARED_POSIX */
35     bool do_unlink:1;
36
37     /* Only for type = PA_MEM_TYPE_SHARED_MEMFD
38      *
39      * To avoid fd leaks, we keep this fd open only until we pass it
40      * to the other PA endpoint over unix domain socket.
41      *
42      * When we don't have ownership for the memfd fd in question (e.g.
43      * pa_shm_attach()), or the file descriptor has now been closed,
44      * this is set to -1.
45      *
46      * For the special case of a global mempool, we keep this fd
47      * always open. Check comments on top of pa_mempool_new() for
48      * rationale. */
49     int fd;
50 } pa_shm;
51
52 int pa_shm_create_rw(pa_shm *m, pa_mem_type_t type, size_t size, mode_t mode);
53 int pa_shm_attach(pa_shm *m, pa_mem_type_t type, unsigned id, int memfd_fd, bool writable);
54
55 void pa_shm_punch(pa_shm *m, size_t offset, size_t size);
56
57 void pa_shm_free(pa_shm *m);
58
59 int pa_shm_cleanup(void);
60
61 #endif