summaryrefslogtreecommitdiffstats
path: root/src/pulsecore/memchunk.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2007-06-11 12:08:37 +0000
committerLennart Poettering <lennart@poettering.net>2007-06-11 12:08:37 +0000
commit00da37f2c448096cdd54481b072db47b2f253141 (patch)
treecb6c51231fa498831b3e63660105ec00ea98d8f5 /src/pulsecore/memchunk.c
parent6aeec56708f4af2da0b83fdd65a0d153b9bed272 (diff)
Merge HUGE set of changes temporarily into a branch, to allow me to move them from one machine to another (lock-free and stuff)
git-svn-id: file:///home/lennart/svn/public/pulseaudio/branches/lennart@1469 fefdeb5f-60dc-0310-8127-8f9354f1896f
Diffstat (limited to 'src/pulsecore/memchunk.c')
-rw-r--r--src/pulsecore/memchunk.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/pulsecore/memchunk.c b/src/pulsecore/memchunk.c
index 7111e1ec..f00cc9e7 100644
--- a/src/pulsecore/memchunk.c
+++ b/src/pulsecore/memchunk.c
@@ -37,22 +37,25 @@
void pa_memchunk_make_writable(pa_memchunk *c, size_t min) {
pa_memblock *n;
size_t l;
+ void *tdata, *sdata;
assert(c);
assert(c->memblock);
- assert(PA_REFCNT_VALUE(c->memblock) > 0);
- if (PA_REFCNT_VALUE(c->memblock) == 1 &&
- !c->memblock->read_only &&
- c->memblock->length >= c->index+min)
+ if (pa_memblock_is_read_only(c->memblock) &&
+ pa_memblock_get_length(c->memblock) >= c->index+min)
return;
l = c->length;
if (l < min)
l = min;
- n = pa_memblock_new(c->memblock->pool, l);
- memcpy(n->data, (uint8_t*) c->memblock->data + c->index, c->length);
+ n = pa_memblock_new(pa_memblock_get_pool(c->memblock), l);
+ tdata = pa_memblock_acquire(n);
+ sdata = pa_memblock_acquire(c->memblock);
+ memcpy(tdata, (uint8_t*) sdata + c->index, c->length);
+ pa_memblock_release(n);
+ pa_memblock_release(c->memblock);
pa_memblock_unref(c->memblock);
c->memblock = n;
c->index = 0;