]> code.delx.au - pulseaudio/blob - src/pulsecore/memchunk.h
merge 'lennart' branch back into trunk.
[pulseaudio] / src / pulsecore / memchunk.h
1 #ifndef foomemchunkhfoo
2 #define foomemchunkhfoo
3
4 /* $Id$ */
5
6 /***
7 This file is part of PulseAudio.
8
9 Copyright 2004-2006 Lennart Poettering
10
11 PulseAudio is free software; you can redistribute it and/or modify
12 it under the terms of the GNU Lesser General Public License as
13 published by the Free Software Foundation; either version 2.1 of the
14 License, or (at your option) any later version.
15
16 PulseAudio is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 Lesser General Public License for more details.
20
21 You should have received a copy of the GNU Lesser General Public
22 License along with PulseAudio; if not, write to the Free Software
23 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
24 USA.
25 ***/
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 typedef struct pa_memchunk {
34 pa_memblock *memblock;
35 size_t index, length;
36 } pa_memchunk;
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 cotaining 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 #endif