aboutsummaryrefslogtreecommitdiffstats
path: root/OpenAL32
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2018-12-26 21:22:17 -0800
committerChris Robinson <[email protected]>2018-12-26 21:22:17 -0800
commit8a0295503db394ea895bfa079d1f3eda0d758e61 (patch)
tree21a1a1e63fe148dc087ad2c35ce94a49418ef900 /OpenAL32
parent4f253a935a14e49a77516a56e0d4c6d6177a56b6 (diff)
Clean up the ring buffer struct and use member functions
Diffstat (limited to 'OpenAL32')
-rw-r--r--OpenAL32/alSource.cpp9
-rw-r--r--OpenAL32/event.cpp14
2 files changed, 13 insertions, 10 deletions
diff --git a/OpenAL32/alSource.cpp b/OpenAL32/alSource.cpp
index b70fc872..03375e2d 100644
--- a/OpenAL32/alSource.cpp
+++ b/OpenAL32/alSource.cpp
@@ -691,13 +691,14 @@ void SendStateChangeEvent(ALCcontext *context, ALuint id, ALenum state)
* and we don't want state change messages to occur out of order, so send
* it through the async queue to ensure proper ordering.
*/
- auto evt_data = ll_ringbuffer_get_write_vector(context->AsyncEvents).first;
- if(evt_data.len < 1) return;
+ RingBuffer *ring{context->AsyncEvents};
+ auto evt_vec = ring->getWriteVector();
+ if(evt_vec.first.len < 1) return;
- AsyncEvent *evt{new (evt_data.buf) AsyncEvent{EventType_SourceStateChange}};
+ AsyncEvent *evt{new (evt_vec.first.buf) AsyncEvent{EventType_SourceStateChange}};
evt->u.srcstate.id = id;
evt->u.srcstate.state = state;
- ll_ringbuffer_write_advance(context->AsyncEvents, 1);
+ ring->writeAdvance(1);
context->EventSem.post();
}
diff --git a/OpenAL32/event.cpp b/OpenAL32/event.cpp
index 6399603b..f14c3229 100644
--- a/OpenAL32/event.cpp
+++ b/OpenAL32/event.cpp
@@ -17,10 +17,11 @@
static int EventThread(ALCcontext *context)
{
+ RingBuffer *ring{context->AsyncEvents};
bool quitnow{false};
while(LIKELY(!quitnow))
{
- auto evt_data = ll_ringbuffer_get_read_vector(context->AsyncEvents).first;
+ auto evt_data = ring->getReadVector().first;
if(evt_data.len == 0)
{
context->EventSem.wait();
@@ -37,11 +38,11 @@ static int EventThread(ALCcontext *context)
*/
const struct EventAutoDestructor {
AsyncEvent &evt;
- ll_ringbuffer *ring;
+ RingBuffer *ring;
~EventAutoDestructor()
{
evt.~AsyncEvent();
- ll_ringbuffer_read_advance(ring, 1);
+ ring->readAdvance(1);
}
} _{evt, context->AsyncEvents};
@@ -110,16 +111,17 @@ void StartEventThrd(ALCcontext *ctx)
void StopEventThrd(ALCcontext *ctx)
{
static constexpr AsyncEvent kill_evt{EventType_KillThread};
- ll_ringbuffer_data evt_data = ll_ringbuffer_get_write_vector(ctx->AsyncEvents).first;
+ RingBuffer *ring{ctx->AsyncEvents};
+ auto evt_data = ring->getWriteVector().first;
if(evt_data.len == 0)
{
do {
std::this_thread::yield();
- evt_data = ll_ringbuffer_get_write_vector(ctx->AsyncEvents).first;
+ evt_data = ring->getWriteVector().first;
} while(evt_data.len == 0);
}
new (evt_data.buf) AsyncEvent{kill_evt};
- ll_ringbuffer_write_advance(ctx->AsyncEvents, 1);
+ ring->writeAdvance(1);
ctx->EventSem.post();
if(ctx->EventThread.joinable())