summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2007-12-16 19:30:57 -0800
committerChris Robinson <[email protected]>2007-12-16 19:30:57 -0800
commit1fa1edf16b24ea758d66b19b43e9697163c80a70 (patch)
tree8b5939e8623fc492821320d349e56613c809b18e
parent19156ab89520662af94ad71fd2d14987091efb9a (diff)
Fix ring buffer size and overrun detection
-rw-r--r--Alc/alcRing.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/Alc/alcRing.c b/Alc/alcRing.c
index 0e52ad3c..c2384a83 100644
--- a/Alc/alcRing.c
+++ b/Alc/alcRing.c
@@ -70,7 +70,7 @@ void DestroyRingBuffer(RingBuffer *ring)
ALsizei RingBufferSize(RingBuffer *ring)
{
- return (ring->read_pos+1-ring->write_pos+ring->length) % ring->length;
+ return (ring->write_pos-ring->read_pos-1+ring->length) % ring->length;
}
void WriteRingBuffer(RingBuffer *ring, const ALubyte *data, ALsizei len)
@@ -79,8 +79,8 @@ void WriteRingBuffer(RingBuffer *ring, const ALubyte *data, ALsizei len)
EnterCriticalSection(&ring->cs);
- if((ring->write_pos-ring->read_pos+ring->length)%ring->length < len)
- ring->read_pos = ((ring->write_pos+len) % ring->length) + 1;
+ if((ring->read_pos-ring->write_pos+ring->length)%ring->length < len)
+ ring->read_pos = (ring->write_pos+len) % ring->length;
if(remain < len)
{