From ef68e5d0ff0b3242023418f22420694385b8ddbe Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Sun, 7 Jun 2009 21:34:05 -0700 Subject: Protect ring buffer access with the lock --- Alc/alcRing.c | 6 ++++-- 1 file 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); -- cgit v1.2.3