Add a disconnected event type
This commit is contained in:
@@ -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];
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -612,6 +612,7 @@ enum {
|
||||
EventType_Error = 1<<2,
|
||||
EventType_Performance = 1<<3,
|
||||
EventType_Deprecated = 1<<4,
|
||||
EventType_Disconnected = 1<<5,
|
||||
};
|
||||
|
||||
typedef struct AsyncEvent {
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user