]> code.delx.au - pulseaudio/blob - src/pulsecore/memchunk.h
remap: Change remapping function argument type from void to int16_t / float as approp...
[pulseaudio] / src / pulsecore / memchunk.h
1 #ifndef foomemchunkhfoo
2 #define foomemchunkhfoo
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 typedef struct pa_memchunk pa_memchunk;
26
27 #include <pulsecore/memblock.h>
28
29 /* A memchunk describes a part of a memblock. In contrast to the memblock, a
30 * memchunk is not allocated dynamically or reference counted, instead
31 * it is usually stored on the stack and copied around */
32
33 struct pa_memchunk {
34 pa_memblock *memblock;
35 size_t index, length;
36 };
37
38 /* Make a memchunk writable, i.e. make sure that the caller may have
39 * exclusive access to the memblock and it is not read-only. If needed
40 * the memblock in the structure is replaced by a copy. If min is not
41 * 0 it is made sure that the returned memblock is at least of the
42 * specified size, i.e. is enlarged if necessary. */
43 pa_memchunk* pa_memchunk_make_writable(pa_memchunk *c, size_t min);
44
45 /* Invalidate a memchunk. This does not free the containing memblock,
46 * but sets all members to zero. */
47 pa_memchunk* pa_memchunk_reset(pa_memchunk *c);
48
49 /* Map a memory chunk back into memory if it was swapped out */
50 pa_memchunk *pa_memchunk_will_need(const pa_memchunk *c);
51
52 /* Copy the data in the src memchunk to the dst memchunk */
53 pa_memchunk* pa_memchunk_memcpy(pa_memchunk *dst, pa_memchunk *src);
54
55 /* Return true if any field is set != 0 */
56 bool pa_memchunk_isset(pa_memchunk *c);
57
58 #endif