diff options
-rw-r--r-- | Alc/mixvoice.cpp | 27 | ||||
-rw-r--r-- | OpenAL32/Include/alMain.h | 4 | ||||
-rw-r--r-- | OpenAL32/event.cpp | 11 |
3 files changed, 24 insertions, 18 deletions
diff --git a/Alc/mixvoice.cpp b/Alc/mixvoice.cpp index d19a4861..04bb1130 100644 --- a/Alc/mixvoice.cpp +++ b/Alc/mixvoice.cpp @@ -195,19 +195,6 @@ void aluInitMixer(void) namespace { -static void SendAsyncEvent(ALCcontext *context, ALuint enumtype, ALenum type, - ALuint objid, ALuint param, const char *msg) -{ - AsyncEvent evt = ASYNC_EVENT(enumtype); - evt.u.user.type = type; - evt.u.user.id = objid; - evt.u.user.param = param; - strcpy(evt.u.user.msg, msg); - if(ll_ringbuffer_write(context->AsyncEvents, &evt, 1) == 1) - context->EventSem.post(); -} - - /* Base template left undefined. Should be marked =delete, but Clang 3.8.1 * chokes on that given the inline specializations. */ @@ -237,8 +224,8 @@ inline void LoadSampleArray(ALfloat *RESTRICT dst, const void *src, ALint srcste dst[i] += LoadSample<T>(ssrc[i*srcstep]); } -static void LoadSamples(ALfloat *RESTRICT dst, const ALvoid *RESTRICT src, ALint srcstep, - enum FmtType srctype, ALsizei samples) +void LoadSamples(ALfloat *RESTRICT dst, const ALvoid *RESTRICT src, ALint srcstep, FmtType srctype, + ALsizei samples) { #define HANDLE_FMT(T) \ case T: LoadSampleArray<T>(dst, src, srcstep, samples); break @@ -734,9 +721,13 @@ ALboolean MixSource(ALvoice *voice, ALuint SourceID, ALCcontext *Context, ALsize /* Send any events now, after the position/buffer info was updated. */ ALbitfieldSOFT enabledevt{Context->EnabledEvts.load(std::memory_order_acquire)}; if(buffers_done > 0 && (enabledevt&EventType_BufferCompleted)) - SendAsyncEvent(Context, EventType_BufferCompleted, - AL_EVENT_TYPE_BUFFER_COMPLETED_SOFT, SourceID, buffers_done, "Buffer completed" - ); + { + AsyncEvent evt{ASYNC_EVENT(EventType_BufferCompleted)}; + evt.u.bufcomp.id = SourceID; + evt.u.bufcomp.count = buffers_done; + if(ll_ringbuffer_write(Context->AsyncEvents, &evt, 1) == 1) + Context->EventSem.post(); + } return isplaying; } diff --git a/OpenAL32/Include/alMain.h b/OpenAL32/Include/alMain.h index bff3d52e..75dc6c74 100644 --- a/OpenAL32/Include/alMain.h +++ b/OpenAL32/Include/alMain.h @@ -850,6 +850,10 @@ struct AsyncEvent { ALenum state; } srcstate; struct { + ALuint id; + ALsizei count; + } bufcomp; + struct { ALenum type; ALuint id; ALuint param; diff --git a/OpenAL32/event.cpp b/OpenAL32/event.cpp index d263acc5..1a4e1df0 100644 --- a/OpenAL32/event.cpp +++ b/OpenAL32/event.cpp @@ -55,6 +55,17 @@ static int EventThread(ALCcontext *context) evt.u.srcstate.state, msg.length(), msg.c_str(), context->EventParam ); } + else if(evt.EnumType == EventType_BufferCompleted) + { + if(!(enabledevts&EventType_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"; + context->EventCb(AL_EVENT_TYPE_BUFFER_COMPLETED_SOFT, evt.u.bufcomp.id, + evt.u.bufcomp.count, msg.length(), msg.c_str(), context->EventParam + ); + } else if((enabledevts&evt.EnumType) == evt.EnumType) context->EventCb(evt.u.user.type, evt.u.user.id, evt.u.user.param, (ALsizei)strlen(evt.u.user.msg), evt.u.user.msg, context->EventParam |