diff options
author | Chris Robinson <[email protected]> | 2009-06-07 21:34:05 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2009-06-07 21:34:05 -0700 |
commit | ef68e5d0ff0b3242023418f22420694385b8ddbe (patch) | |
tree | c267646489a5d500aceb8f1704eb2fc4542b033f | |
parent | c6f3a4e0622c93ef832d6fa0ade3baff0b417fc9 (diff) |
Protect ring buffer access with the lock
-rw-r--r-- | Alc/alcRing.c | 6 |
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); |