From 284516185f90412c22dfa9a28cb93fb344af591b Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 18 May 2007 00:10:02 +0000 Subject: really prefix everything with "sa_" git-svn-id: file:///home/lennart/svn/public/libsydney/trunk@28 9ba3c220-e4d3-45a2-8aa3-73fcc9aff6ce --- bufferq.c | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) (limited to 'bufferq.c') diff --git a/bufferq.c b/bufferq.c index df22ec3..c4c3ec3 100644 --- a/bufferq.c +++ b/bufferq.c @@ -4,7 +4,7 @@ #include "macro.h" #include "bufferq.h" -int bufferq_init(bufferq_t *q, unsigned nchannels, size_t sample_size) { +int sa_bufferq_init(sa_bufferq_t *q, unsigned nchannels, size_t sample_size) { sa_assert(q); sa_assert(sample_size > 0); sa_assert(nchannels > 0); @@ -13,10 +13,10 @@ int bufferq_init(bufferq_t *q, unsigned nchannels, size_t sample_size) { q->sample_size = sample_size; q->nchannels = nchannels; - if (!(q->items = sa_new0(bufferq_item_t*, nchannels))) + if (!(q->items = sa_new0(sa_bufferq_item_t*, nchannels))) return SA_ERROR_OOM; - if (!(q->last = sa_new0(bufferq_item_t*, nchannels))) { + if (!(q->last = sa_new0(sa_bufferq_item_t*, nchannels))) { sa_free(q->items); q->items = NULL; return SA_ERROR_OOM; @@ -25,15 +25,15 @@ int bufferq_init(bufferq_t *q, unsigned nchannels, size_t sample_size) { return SA_SUCCESS; } -void bufferq_done(bufferq_t *q) { +void sa_bufferq_done(sa_bufferq_t *q) { unsigned u; sa_assert(q); for (u = 0; u < q->nchannels; u++) { - bufferq_item_t *i; + sa_bufferq_item_t *i; while ((i = q->items[u])) { - SA_LLIST_REMOVE(bufferq_item_t, bufferq, q->items[u], i); + SA_LLIST_REMOVE(sa_bufferq_item_t, bufferq, q->items[u], i); sa_free(i); } } @@ -42,21 +42,21 @@ void bufferq_done(bufferq_t *q) { sa_free(q->last); } -static bufferq_item_t* bufferq_item_new(size_t size) { - bufferq_item_t *i; +static sa_bufferq_item_t* bufferq_item_new(size_t size) { + sa_bufferq_item_t *i; sa_assert(size > 0); - if (!(i = sa_malloc(ALIGN(sizeof(bufferq_item_t)) + size))) + if (!(i = sa_malloc(ALIGN(sizeof(sa_bufferq_item_t)) + size))) return i; - SA_LLIST_ITEM_INIT(bufferq_item_t, bufferq, i); + SA_LLIST_ITEM_INIT(sa_bufferq_item_t, bufferq, i); return i; } -int bufferq_push(bufferq_t *q, unsigned channel, const void *data, size_t nbytes, int64_t offset, sa_seek_t whence) { +int sa_bufferq_push(sa_bufferq_t *q, unsigned channel, const void *data, size_t nbytes, int64_t offset, sa_seek_t whence) { int64_t idx; - bufferq_item_t *i, *j; + sa_bufferq_item_t *i, *j; sa_assert(q); @@ -107,11 +107,11 @@ int bufferq_push(bufferq_t *q, unsigned channel, const void *data, size_t nbytes if (!(j = bufferq_item_new(l))) return SA_ERROR_OOM; - memcpy(BUFFERQ_ITEM_DATA(j), data, l); + memcpy(SA_BUFFERQ_ITEM_DATA(j), data, l); j->idx = idx; j->size = l; - SA_LLIST_INSERT_BEFORE(bufferq_item_t, bufferq, q->items[channel], i, j); + SA_LLIST_INSERT_BEFORE(sa_bufferq_item_t, bufferq, q->items[channel], i, j); idx += l; data += l; @@ -127,7 +127,7 @@ int bufferq_push(bufferq_t *q, unsigned channel, const void *data, size_t nbytes if (l > i->idx + i->size - idx) l = i->idx + i->size - idx; - memcpy((uint8_t*) BUFFERQ_ITEM_DATA(i) + (idx - i->idx), data, l); + memcpy((uint8_t*) SA_BUFFERQ_ITEM_DATA(i) + (idx - i->idx), data, l); idx += l; data += l; @@ -141,14 +141,14 @@ int bufferq_push(bufferq_t *q, unsigned channel, const void *data, size_t nbytes if (!(j = bufferq_item_new(nbytes))) return SA_ERROR_OOM; - memcpy(BUFFERQ_ITEM_DATA(j), data, nbytes); + memcpy(SA_BUFFERQ_ITEM_DATA(j), data, nbytes); j->idx = idx; j->size = nbytes; if (q->last[channel]) - SA_LLIST_INSERT_AFTER(bufferq_item_t, bufferq, q->items[channel], q->last[channel], j); + SA_LLIST_INSERT_AFTER(sa_bufferq_item_t, bufferq, q->items[channel], q->last[channel], j); else - SA_LLIST_PREPEND(bufferq_item_t, bufferq, q->items[channel], j); + SA_LLIST_PREPEND(sa_bufferq_item_t, bufferq, q->items[channel], j); q->last[channel] = j; } @@ -161,7 +161,7 @@ int bufferq_push(bufferq_t *q, unsigned channel, const void *data, size_t nbytes return SA_SUCCESS; } -int bufferq_get(bufferq_t *q, void *i[], size_t *bytes) { +int sa_bufferq_get(sa_bufferq_t *q, void *i[], size_t *bytes) { int first = 1; unsigned u; sa_assert(q); @@ -186,7 +186,7 @@ int bufferq_get(bufferq_t *q, void *i[], size_t *bytes) { } else { int64_t l; - i[u] = (uint8_t*) BUFFERQ_ITEM_DATA(q->items[u]) + q->read_index - q->items[u]->idx; + i[u] = (uint8_t*) SA_BUFFERQ_ITEM_DATA(q->items[u]) + q->read_index - q->items[u]->idx; l = q->items[u]->size - (q->read_index - q->items[u]->idx); @@ -205,7 +205,7 @@ int bufferq_get(bufferq_t *q, void *i[], size_t *bytes) { } -int bufferq_drop(bufferq_t *q, int64_t bytes) { +int sa_bufferq_drop(sa_bufferq_t *q, int64_t bytes) { unsigned u; sa_assert(q); @@ -214,14 +214,14 @@ int bufferq_drop(bufferq_t *q, int64_t bytes) { for (u = 0; u < q->nchannels; u++) { - bufferq_item_t *i; + sa_bufferq_item_t *i; i = q->items[u]; while (i && q->read_index >= i->idx + i->size) { - bufferq_item_t *n = i->bufferq_next; + sa_bufferq_item_t *n = i->bufferq_next; - SA_LLIST_REMOVE(bufferq_item_t, bufferq, q->items[u], i); + SA_LLIST_REMOVE(sa_bufferq_item_t, bufferq, q->items[u], i); sa_free(i); i = n; -- cgit