aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2018-02-03 01:07:06 -0800
committerChris Robinson <[email protected]>2018-02-03 01:07:06 -0800
commit40bda4d93f15b5b089b6736eb9fd2d04f8e683eb (patch)
treee52b16dc302bf930848269e12ce379eab3396e02
parent8f4c078fb569d47dcd53bfb1b69ac2da8ebb0341 (diff)
Add a disconnected event type
-rw-r--r--Alc/ALu.c17
-rw-r--r--Alc/inprogext.h1
-rw-r--r--OpenAL32/Include/alMain.h1
-rw-r--r--OpenAL32/Include/alu.h2
-rw-r--r--OpenAL32/event.c2
5 files changed, 22 insertions, 1 deletions
diff --git a/Alc/ALu.c b/Alc/ALu.c
index 8d2e5727..2a89f455 100644
--- a/Alc/ALu.c
+++ b/Alc/ALu.c
@@ -38,6 +38,7 @@
#include "uhjfilter.h"
#include "bformatdec.h"
#include "static_assert.h"
+#include "ringbuffer.h"
#include "fpu_modes.h"
#include "cpu_caps.h"
@@ -1859,6 +1860,22 @@ void aluHandleDisconnect(ALCdevice *device)
while(ctx)
{
ALsizei i;
+
+ if((ATOMIC_LOAD(&ctx->EnabledEvts, almemory_order_acquire)&EventType_Disconnected))
+ {
+ AsyncEvent evt;
+ evt.EnumType = EventType_Disconnected;
+ evt.Type = AL_EVENT_TYPE_DISCONNECTED_SOFT;
+ evt.ObjectId = 0;
+ evt.Param = 0;
+ strcpy(evt.Message, "Device disconnected");
+ if(ll_ringbuffer_write_space(ctx->AsyncEvents) > 0)
+ {
+ ll_ringbuffer_write(ctx->AsyncEvents, (const char*)&evt, 1);
+ alsem_post(&ctx->EventSem);
+ }
+ }
+
for(i = 0;i < ctx->VoiceCount;i++)
{
ALvoice *voice = ctx->Voices[i];
diff --git a/Alc/inprogext.h b/Alc/inprogext.h
index 721f2370..619b604f 100644
--- a/Alc/inprogext.h
+++ b/Alc/inprogext.h
@@ -56,6 +56,7 @@ AL_API void AL_APIENTRY alFlushMappedBufferSOFT(ALuint buffer, ALsizei offset, A
#define AL_EVENT_TYPE_ERROR_SOFT 0x1224
#define AL_EVENT_TYPE_PERFORMANCE_SOFT 0x1225
#define AL_EVENT_TYPE_DEPRECATED_SOFT 0x1226
+#define AL_EVENT_TYPE_DISCONNECTED_SOFT 0x1227
typedef void (AL_APIENTRY*ALEVENTPROCSOFT)(ALenum eventType, ALuint object, ALuint param,
ALsizei length, const ALchar *message,
void *userParam);
diff --git a/OpenAL32/Include/alMain.h b/OpenAL32/Include/alMain.h
index bc5a27c8..5c2435a4 100644
--- a/OpenAL32/Include/alMain.h
+++ b/OpenAL32/Include/alMain.h
@@ -612,6 +612,7 @@ enum {
EventType_Error = 1<<2,
EventType_Performance = 1<<3,
EventType_Deprecated = 1<<4,
+ EventType_Disconnected = 1<<5,
};
typedef struct AsyncEvent {
diff --git a/OpenAL32/Include/alu.h b/OpenAL32/Include/alu.h
index 2e2e1f5a..0d39729d 100644
--- a/OpenAL32/Include/alu.h
+++ b/OpenAL32/Include/alu.h
@@ -519,7 +519,7 @@ inline void ComputeFirstOrderGains(const BFMixParams *foa, const ALfloat mtx[4],
ALboolean MixSource(struct ALvoice *voice, ALuint SourceID, ALCcontext *Context, ALsizei SamplesToDo);
void aluMixData(ALCdevice *device, ALvoid *OutBuffer, ALsizei NumSamples);
-/* Caller must lock the device. */
+/* Caller must lock the device, and the mixer must not be running. */
void aluHandleDisconnect(ALCdevice *device);
void UpdateContextProps(ALCcontext *context);
diff --git a/OpenAL32/event.c b/OpenAL32/event.c
index 38c12d98..f65efc7c 100644
--- a/OpenAL32/event.c
+++ b/OpenAL32/event.c
@@ -61,6 +61,8 @@ AL_API void AL_APIENTRY alEventControlSOFT(ALsizei count, const ALenum *types, A
flags |= EventType_Performance;
else if(types[i] == AL_EVENT_TYPE_DEPRECATED_SOFT)
flags |= EventType_Deprecated;
+ else if(types[i] == AL_EVENT_TYPE_DISCONNECTED_SOFT)
+ flags |= EventType_Disconnected;
else
SETERR_GOTO(context, AL_INVALID_ENUM, done, "Invalid event type 0x%04x", types[i]);
}