From 7dbabc47bbfe517cd85e8b25b360413e511b3aec Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Sun, 2 Sep 2007 20:37:55 +0000 Subject: add new pa_memchunk_will_need() API, similar to pa_memblock_will_need() git-svn-id: file:///home/lennart/svn/public/pulseaudio/branches/lennart@1747 fefdeb5f-60dc-0310-8127-8f9354f1896f --- src/pulsecore/memchunk.c | 19 +++++++++++++++++++ src/pulsecore/memchunk.h | 3 +++ 2 files changed, 22 insertions(+) (limited to 'src') diff --git a/src/pulsecore/memchunk.c b/src/pulsecore/memchunk.c index 20ddb11d..319767f1 100644 --- a/src/pulsecore/memchunk.c +++ b/src/pulsecore/memchunk.c @@ -29,8 +29,11 @@ #include #include #include +#include #include +#include +#include #include "memchunk.h" @@ -72,3 +75,19 @@ pa_memchunk* pa_memchunk_reset(pa_memchunk *c) { return c; } + +pa_memchunk *pa_memchunk_will_need(pa_memchunk *c) { + void *p; + + pa_assert(c); + pa_assert(c->memblock); + + /* A version of pa_memblock_will_need() that works on memchunks + * instead of memblocks */ + + p = (uint8_t*) pa_memblock_acquire(c->memblock) + c->index; + pa_will_need(p, c->length); + pa_memblock_release(c->memblock); + + return c; +} diff --git a/src/pulsecore/memchunk.h b/src/pulsecore/memchunk.h index 10cab2b9..17e5f75f 100644 --- a/src/pulsecore/memchunk.h +++ b/src/pulsecore/memchunk.h @@ -44,4 +44,7 @@ pa_memchunk* pa_memchunk_make_writable(pa_memchunk *c, size_t min); * but sets all members to zero. */ pa_memchunk* pa_memchunk_reset(pa_memchunk *c); +/* Map a memory chunk back into memory if it was swapped out */ +pa_memchunk *pa_memchunk_will_need(pa_memchunk *c); + #endif -- cgit