[vlc-commits] TPCircularBuffer: merge with upstream
Felix Paul Kühne
git at videolan.org
Thu Apr 4 19:31:40 CEST 2013
vlc | branch: master | Felix Paul Kühne <fkuehne at videolan.org> | Thu Apr 4 19:29:46 2013 +0200| [157bcc00b32ecbbe050b81fedbbb19f41772da56] | committer: Felix Paul Kühne
TPCircularBuffer: merge with upstream
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=157bcc00b32ecbbe050b81fedbbb19f41772da56
---
modules/audio_output/TPCircularBuffer.h | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/modules/audio_output/TPCircularBuffer.h b/modules/audio_output/TPCircularBuffer.h
index c7f75a2..b4932ed 100644
--- a/modules/audio_output/TPCircularBuffer.h
+++ b/modules/audio_output/TPCircularBuffer.h
@@ -24,6 +24,7 @@
#include <libkern/OSAtomic.h>
#include <string.h>
+#include <assert.h>
#ifdef __cplusplus
extern "C" {
@@ -95,14 +96,16 @@ static __inline__ __attribute__((always_inline)) void* TPCircularBufferTail(TPCi
static __inline__ __attribute__((always_inline)) void TPCircularBufferConsume(TPCircularBuffer *buffer, int32_t amount) {
buffer->tail = (buffer->tail + amount) % buffer->length;
OSAtomicAdd32Barrier(-amount, &buffer->fillCount);
+ assert(buffer->fillCount >= 0);
}
/*!
* Version of TPCircularBufferConsume without the memory barrier, for more optimal use in single-threaded contexts
*/
- static __inline__ __attribute__((always_inline)) void TPCircularBufferConsumeNoBarrier(TPCircularBuffer *buffer, int32_t amount) {
+static __inline__ __attribute__((always_inline)) void TPCircularBufferConsumeNoBarrier(TPCircularBuffer *buffer, int32_t amount) {
buffer->tail = (buffer->tail + amount) % buffer->length;
buffer->fillCount -= amount;
+ assert(buffer->fillCount >= 0);
}
/*!
@@ -134,6 +137,7 @@ static __inline__ __attribute__((always_inline)) void* TPCircularBufferHead(TPCi
static __inline__ __attribute__((always_inline)) void TPCircularBufferProduce(TPCircularBuffer *buffer, int amount) {
buffer->head = (buffer->head + amount) % buffer->length;
OSAtomicAdd32Barrier(amount, &buffer->fillCount);
+ assert(buffer->fillCount <= buffer->length);
}
/*!
@@ -142,6 +146,7 @@ static __inline__ __attribute__((always_inline)) void TPCircularBufferProduce(TP
static __inline__ __attribute__((always_inline)) void TPCircularBufferProduceNoBarrier(TPCircularBuffer *buffer, int amount) {
buffer->head = (buffer->head + amount) % buffer->length;
buffer->fillCount += amount;
+ assert(buffer->fillCount <= buffer->length);
}
/*!
More information about the vlc-commits
mailing list