From 207871fd9b534c896f604bdd2988580c8c8f9bc9 Mon Sep 17 00:00:00 2001 From: Johns Date: Sun, 22 Apr 2012 17:17:54 +0200 Subject: Make audio ring buffer size a multiple of 3,5,7,8. --- ringbuffer.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'ringbuffer.c') diff --git a/ringbuffer.c b/ringbuffer.c index 81722e2..9466852 100644 --- a/ringbuffer.c +++ b/ringbuffer.c @@ -48,6 +48,18 @@ struct _ring_buffer_ atomic_t Filled; ///< how many of the buffer is used }; +/** +** Reset ring buffer pointers. +** +** @param rb Ring buffer to reset read/write pointers. +*/ +void RingBufferReset(RingBuffer * rb) +{ + rb->ReadPointer = rb->Buffer; + rb->WritePointer = rb->Buffer; + atomic_set(&rb->Filled, 0); +} + /** ** Allocate a new ring buffer. ** @@ -69,10 +81,8 @@ RingBuffer *RingBufferNew(size_t size) } rb->Size = size; - rb->ReadPointer = rb->Buffer; - rb->WritePointer = rb->Buffer; rb->BufferEnd = rb->Buffer + size; - atomic_set(&rb->Filled, 0); + RingBufferReset(rb); return rb; } @@ -89,7 +99,7 @@ void RingBufferDel(RingBuffer * rb) /** ** Advance write pointer in ring buffer. ** -** @param rb Ring buffer to adance write pointer. +** @param rb Ring buffer to advance write pointer. ** @param cnt Number of bytes to be adavanced. ** ** @returns Number of bytes that could be advanced in ring buffer. @@ -198,7 +208,7 @@ size_t RingBufferGetWritePointer(RingBuffer * rb, void **wp) /** ** Advance read pointer in ring buffer. ** -** @param rb Ring buffer to adance read pointer. +** @param rb Ring buffer to advance read pointer. ** @param cnt Number of bytes to be advanced. ** ** @returns Number of bytes that could be advanced in ring buffer. -- cgit v1.2.3