Git init
[framework/multimedia/pulseaudio.git] / 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 #include <pulsecore/memblock.h>
26
27 /* A memchunk describes a part of a memblock. In contrast to the memblock, a
28  * memchunk is not allocated dynamically or reference counted, instead
29  * it is usually stored on the stack and copied around */
30
31 typedef struct pa_memchunk {
32     pa_memblock *memblock;
33     size_t index, length;
34 } pa_memchunk;
35
36 /* Make a memchunk writable, i.e. make sure that the caller may have
37  * exclusive access to the memblock and it is not read_only. If needed
38  * the memblock in the structure is replaced by a copy. If min is not
39  * 0 it is made sure that the returned memblock is at least of the
40  * specified size, i.e. is enlarged if necessary. */
41 pa_memchunk* pa_memchunk_make_writable(pa_memchunk *c, size_t min);
42
43 /* Invalidate a memchunk. This does not free the cotaining memblock,
44  * but sets all members to zero. */
45 pa_memchunk* pa_memchunk_reset(pa_memchunk *c);
46
47 /* Map a memory chunk back into memory if it was swapped out */
48 pa_memchunk *pa_memchunk_will_need(const pa_memchunk *c);
49
50 /* Copy the data in the src memchunk to the dst memchunk */
51 pa_memchunk* pa_memchunk_memcpy(pa_memchunk *dst, pa_memchunk *src);
52
53 #endif