aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Alc/alc.cpp5
-rw-r--r--Alc/alcontext.h2
-rw-r--r--Alc/alu.cpp12
-rw-r--r--Alc/mixvoice.cpp8
-rw-r--r--OpenAL32/alSource.cpp2
-rw-r--r--OpenAL32/event.cpp6
6 files changed, 16 insertions, 19 deletions
diff --git a/Alc/alc.cpp b/Alc/alc.cpp
index 27475652..9a93fbdc 100644
--- a/Alc/alc.cpp
+++ b/Alc/alc.cpp
@@ -2369,7 +2369,7 @@ static ALvoid InitContext(ALCcontext *Context)
listener.Params.mDistanceModel = Context->mDistanceModel;
- Context->AsyncEvents = ll_ringbuffer_create(511, sizeof(AsyncEvent), false);
+ Context->AsyncEvents.reset(ll_ringbuffer_create(511, sizeof(AsyncEvent), false));
StartEventThrd(Context);
}
@@ -2484,9 +2484,6 @@ ALCcontext_struct::~ALCcontext_struct()
if(count > 0)
TRACE("Destructed " SZFMT " orphaned event%s\n", count, (count==1)?"":"s");
- delete AsyncEvents;
- AsyncEvents = nullptr;
-
ALCdevice_DecRef(Device);
}
diff --git a/Alc/alcontext.h b/Alc/alcontext.h
index dadb4f8f..f843809b 100644
--- a/Alc/alcontext.h
+++ b/Alc/alcontext.h
@@ -112,7 +112,7 @@ struct ALCcontext_struct {
std::thread EventThread;
al::semaphore EventSem;
- RingBuffer *AsyncEvents{nullptr};
+ std::unique_ptr<RingBuffer> AsyncEvents;
std::atomic<ALbitfieldSOFT> EnabledEvts{0u};
std::mutex EventCbLock;
ALEVENTPROCSOFT EventCb{};
diff --git a/Alc/alu.cpp b/Alc/alu.cpp
index dfbd15a9..672b571b 100644
--- a/Alc/alu.cpp
+++ b/Alc/alu.cpp
@@ -292,11 +292,11 @@ void SendSourceStoppedEvent(ALCcontext *context, ALuint id)
ALbitfieldSOFT enabledevt{context->EnabledEvts.load(std::memory_order_acquire)};
if(!(enabledevt&EventType_SourceStateChange)) return;
- RingBuffer *ring{context->AsyncEvents};
- auto evt_data = ring->getWriteVector().first;
- if(evt_data.len < 1) return;
+ RingBuffer *ring{context->AsyncEvents.get()};
+ 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 = AL_STOPPED;
@@ -419,7 +419,7 @@ bool CalcEffectSlotParams(ALeffectslot *slot, ALCcontext *context, bool force)
/* Otherwise, if it would be deleted, send it off with a release
* event.
*/
- RingBuffer *ring{context->AsyncEvents};
+ RingBuffer *ring{context->AsyncEvents.get()};
auto evt_vec = ring->getWriteVector();
if(LIKELY(evt_vec.first.len > 0))
{
@@ -1839,7 +1839,7 @@ void aluHandleDisconnect(ALCdevice *device, const char *msg, ...)
const ALbitfieldSOFT enabledevt{ctx->EnabledEvts.load(std::memory_order_acquire)};
if((enabledevt&EventType_Disconnected))
{
- RingBuffer *ring{ctx->AsyncEvents};
+ RingBuffer *ring{ctx->AsyncEvents.get()};
auto evt_data = ring->getWriteVector().first;
if(evt_data.len > 0)
{
diff --git a/Alc/mixvoice.cpp b/Alc/mixvoice.cpp
index 48844219..53721201 100644
--- a/Alc/mixvoice.cpp
+++ b/Alc/mixvoice.cpp
@@ -736,11 +736,11 @@ ALboolean MixSource(ALvoice *voice, const ALuint SourceID, ALCcontext *Context,
ALbitfieldSOFT enabledevt{Context->EnabledEvts.load(std::memory_order_acquire)};
if(buffers_done > 0 && (enabledevt&EventType_BufferCompleted))
{
- RingBuffer *ring{Context->AsyncEvents};
- auto evt_data = ring->getWriteVector().first;
- if(evt_data.len > 0)
+ RingBuffer *ring{Context->AsyncEvents.get()};
+ auto evt_vec = ring->getWriteVector();
+ if(evt_vec.first.len > 0)
{
- AsyncEvent *evt{new (evt_data.buf) AsyncEvent{EventType_BufferCompleted}};
+ AsyncEvent *evt{new (evt_vec.first.buf) AsyncEvent{EventType_BufferCompleted}};
evt->u.bufcomp.id = SourceID;
evt->u.bufcomp.count = buffers_done;
ring->writeAdvance(1);
diff --git a/OpenAL32/alSource.cpp b/OpenAL32/alSource.cpp
index ac2979a5..98c79213 100644
--- a/OpenAL32/alSource.cpp
+++ b/OpenAL32/alSource.cpp
@@ -697,7 +697,7 @@ 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.
*/
- RingBuffer *ring{context->AsyncEvents};
+ RingBuffer *ring{context->AsyncEvents.get()};
auto evt_vec = ring->getWriteVector();
if(evt_vec.first.len < 1) return;
diff --git a/OpenAL32/event.cpp b/OpenAL32/event.cpp
index f14c3229..f3474139 100644
--- a/OpenAL32/event.cpp
+++ b/OpenAL32/event.cpp
@@ -17,7 +17,7 @@
static int EventThread(ALCcontext *context)
{
- RingBuffer *ring{context->AsyncEvents};
+ RingBuffer *ring{context->AsyncEvents.get()};
bool quitnow{false};
while(LIKELY(!quitnow))
{
@@ -44,7 +44,7 @@ static int EventThread(ALCcontext *context)
evt.~AsyncEvent();
ring->readAdvance(1);
}
- } _{evt, context->AsyncEvents};
+ } _{evt, context->AsyncEvents.get()};
quitnow = evt.EnumType == EventType_KillThread;
if(UNLIKELY(quitnow)) break;
@@ -111,7 +111,7 @@ void StartEventThrd(ALCcontext *ctx)
void StopEventThrd(ALCcontext *ctx)
{
static constexpr AsyncEvent kill_evt{EventType_KillThread};
- RingBuffer *ring{ctx->AsyncEvents};
+ RingBuffer *ring{ctx->AsyncEvents.get()};
auto evt_data = ring->getWriteVector().first;
if(evt_data.len == 0)
{