diff options
author | Chris Robinson <[email protected]> | 2018-01-11 10:03:26 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2018-01-11 10:03:26 -0800 |
commit | e89c183231d26770f4c8ae80a8d05063c34cf0c9 (patch) | |
tree | 4e0afc97391f196e74361a3f72d757986a580636 /Alc | |
parent | ca9e6a4f9434ca25f821802d1b6e1363b18d7b81 (diff) |
Avoid including alMain.h in ringbuffer.c
Diffstat (limited to 'Alc')
-rw-r--r-- | Alc/ringbuffer.c | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/Alc/ringbuffer.c b/Alc/ringbuffer.c index e2ea2ab5..e029e9b6 100644 --- a/Alc/ringbuffer.c +++ b/Alc/ringbuffer.c @@ -24,7 +24,8 @@ #include <stdlib.h> #include "ringbuffer.h" -#include "alMain.h" +#include "align.h" +#include "atomic.h" #include "threads.h" #include "almalloc.h" #include "compat.h" @@ -49,9 +50,21 @@ struct ll_ringbuffer { ll_ringbuffer_t *ll_ringbuffer_create(size_t sz, size_t elem_sz) { ll_ringbuffer_t *rb; - size_t power_of_two; + size_t power_of_two = 0; - power_of_two = NextPowerOf2((ALuint)sz); + if(sz > 0) + { + power_of_two = sz - 1; + power_of_two |= power_of_two>>1; + power_of_two |= power_of_two>>2; + power_of_two |= power_of_two>>4; + power_of_two |= power_of_two>>8; + power_of_two |= power_of_two>>16; +#if SIZE_MAX > UINT_MAX + power_of_two |= power_of_two>>32; +#endif + } + power_of_two++; if(power_of_two < sz) return NULL; rb = al_malloc(16, sizeof(*rb) + power_of_two*elem_sz); |