Add a disconnected event type

This commit is contained in:
Chris Robinson
2018-02-03 01:07:06 -08:00
parent 8f4c078fb5
commit 40bda4d93f
5 changed files with 22 additions and 1 deletions
+17
View File
@@ -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];
+1
View File
@@ -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);
+1
View File
@@ -612,6 +612,7 @@ enum {
EventType_Error = 1<<2,
EventType_Performance = 1<<3,
EventType_Deprecated = 1<<4,
EventType_Disconnected = 1<<5,
};
typedef struct AsyncEvent {
+1 -1
View File
@@ -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);
+2
View File
@@ -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]);
}