diff options
-rw-r--r-- | al/event.cpp | 23 | ||||
-rw-r--r-- | alc/alu.cpp | 15 |
2 files changed, 24 insertions, 14 deletions
diff --git a/al/event.cpp b/al/event.cpp index 33e28412..4fa1bf56 100644 --- a/al/event.cpp +++ b/al/event.cpp @@ -11,6 +11,7 @@ #include <mutex> #include <new> #include <string> +#include <string_view> #include <thread> #include <utility> @@ -25,6 +26,7 @@ #include "core/except.h" #include "core/logging.h" #include "core/voice_change.h" +#include "debug.h" #include "opthelpers.h" #include "ringbuffer.h" #include "threads.h" @@ -63,11 +65,13 @@ static int EventThread(ALCcontext *context) } auto enabledevts = context->mEnabledEvts.load(std::memory_order_acquire); - if(!context->mEventCb || !enabledevts.test(evt.EnumType)) - continue; + if(!context->mEventCb) continue; if(evt.EnumType == AsyncEvent::SourceStateChange) { + if(!enabledevts.test(AsyncEvent::SourceStateChange)) + continue; + ALuint state{}; std::string msg{"Source ID " + std::to_string(evt.u.srcstate.id)}; msg += " state has changed to "; @@ -95,6 +99,9 @@ static int EventThread(ALCcontext *context) } else if(evt.EnumType == AsyncEvent::BufferCompleted) { + if(!enabledevts.test(AsyncEvent::BufferCompleted)) + continue; + std::string msg{std::to_string(evt.u.bufcomp.count)}; if(evt.u.bufcomp.count == 1) msg += " buffer completed"; else msg += " buffers completed"; @@ -104,9 +111,15 @@ static int EventThread(ALCcontext *context) } else if(evt.EnumType == AsyncEvent::Disconnected) { - context->mEventCb(AL_EVENT_TYPE_DISCONNECTED_SOFT, 0, 0, - static_cast<ALsizei>(strlen(evt.u.disconnect.msg)), evt.u.disconnect.msg, - context->mEventParam); + const std::string_view message{evt.u.disconnect.msg}; + + context->debugMessage(DebugSource::System, DebugType::Error, 0, + DebugSeverity::High, static_cast<ALsizei>(message.length()), message.data()); + + if(enabledevts.test(AsyncEvent::Disconnected)) + context->mEventCb(AL_EVENT_TYPE_DISCONNECTED_SOFT, 0, 0, + static_cast<ALsizei>(message.length()), message.data(), + context->mEventParam); } } while(evt_data.len != 0); } diff --git a/alc/alu.cpp b/alc/alu.cpp index fc22febb..1157aca3 100644 --- a/alc/alu.cpp +++ b/alc/alu.cpp @@ -2178,16 +2178,13 @@ void DeviceBase::handleDisconnect(const char *msg, ...) for(ContextBase *ctx : *mContexts.load()) { - if(ctx->mEnabledEvts.load(std::memory_order_acquire).test(AsyncEvent::Disconnected)) + RingBuffer *ring{ctx->mAsyncEvents.get()}; + auto evt_data = ring->getWriteVector().first; + if(evt_data.len > 0) { - RingBuffer *ring{ctx->mAsyncEvents.get()}; - auto evt_data = ring->getWriteVector().first; - if(evt_data.len > 0) - { - al::construct_at(reinterpret_cast<AsyncEvent*>(evt_data.buf), evt); - ring->writeAdvance(1); - ctx->mEventSem.post(); - } + al::construct_at(reinterpret_cast<AsyncEvent*>(evt_data.buf), evt); + ring->writeAdvance(1); + ctx->mEventSem.post(); } if(!ctx->mStopVoicesOnDisconnect) |