aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2009-06-07 21:34:05 -0700
committerChris Robinson <[email protected]>2009-06-07 21:34:05 -0700
commitef68e5d0ff0b3242023418f22420694385b8ddbe (patch)
treec267646489a5d500aceb8f1704eb2fc4542b033f
parentc6f3a4e0622c93ef832d6fa0ade3baff0b417fc9 (diff)
Protect ring buffer access with the lock
-rw-r--r--Alc/alcRing.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/Alc/alcRing.c b/Alc/alcRing.c
index 23195283..5328c942 100644
--- a/Alc/alcRing.c
+++ b/Alc/alcRing.c
@@ -81,10 +81,11 @@ ALsizei RingBufferSize(RingBuffer *ring)
void WriteRingBuffer(RingBuffer *ring, const ALubyte *data, ALsizei len)
{
- int remain = ring->length - ring->write_pos;
+ int remain;
EnterCriticalSection(&ring->cs);
+ remain = ring->length - ring->write_pos;
if((ring->read_pos-ring->write_pos+ring->length)%ring->length < len)
ring->read_pos = (ring->write_pos+len) % ring->length;
@@ -104,10 +105,11 @@ void WriteRingBuffer(RingBuffer *ring, const ALubyte *data, ALsizei len)
void ReadRingBuffer(RingBuffer *ring, ALubyte *data, ALsizei len)
{
- int remain = ring->length - ring->read_pos;
+ int remain;
EnterCriticalSection(&ring->cs);
+ remain = ring->length - ring->read_pos;
if(remain < len)
{
memcpy(data, ring->mem+(ring->read_pos*ring->frame_size), remain*ring->frame_size);