PipeWire  0.1.5.1
mem.h
Go to the documentation of this file.
1 /* PipeWire
2  * Copyright (C) 2016 Wim Taymans <wim.taymans@gmail.com>
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
17  * Boston, MA 02110-1301, USA.
18  */
19 
20 #ifndef __PIPEWIRE_MEM_H__
21 #define __PIPEWIRE_MEM_H__
22 
23 #include <spa/defs.h>
24 
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
37 };
38 
39 #define PW_MEMBLOCK_FLAG_MAP_READWRITE (PW_MEMBLOCK_FLAG_MAP_READ | PW_MEMBLOCK_FLAG_MAP_WRITE)
40 
43 struct pw_memblock {
45  int fd;
46  off_t offset;
47  void *ptr;
48  size_t size;
49 };
50 
51 int
52 pw_memblock_alloc(enum pw_memblock_flags flags, size_t size, struct pw_memblock *mem);
53 
54 int
55 pw_memblock_map(struct pw_memblock *mem);
56 
57 void
58 pw_memblock_free(struct pw_memblock *mem);
59 
60 #ifdef __cplusplus
61 }
62 #endif
63 
64 #endif /* __PIPEWIRE_MEM_H__ */
enum pw_memblock_flags flags
flags used when allocating
Definition: mem.h:44
Definition: mem.h:32
Definition: mem.h:31
Definition: mem.h:35
pw_memblock_flags
Flags passed to pw_memblock_alloc()
Definition: mem.h:30
void pw_memblock_free(struct pw_memblock *mem)
Free a memblock.
Definition: mem.c:206
int fd
memfd if any
Definition: mem.h:45
int pw_memblock_alloc(enum pw_memblock_flags flags, size_t size, struct pw_memblock *mem)
Create a new memblock.
Definition: mem.c:139
int pw_memblock_map(struct pw_memblock *mem)
Map a memblock.
Definition: mem.c:84
off_t offset
offset of mappable memory
Definition: mem.h:46
void * ptr
ptr to mapped memory
Definition: mem.h:47
Memory block structure.
Definition: mem.h:43
size_t size
size of mapped memory
Definition: mem.h:48
Definition: mem.h:36
Definition: mem.h:33
Definition: mem.h:34