11 AL_API
void AL_APIENTRY
alEventControlSOFT(ALsizei count
, const ALenum
*types
, ALboolean enable
)
14 ALbitfieldSOFT flags
= 0;
17 context
= GetContextRef();
20 if(count
< 0) SETERR_GOTO(context
, AL_INVALID_VALUE
, done
, "Controlling %d events", count
);
21 if(count
== 0) goto done
;
22 if(!types
) SETERR_GOTO(context
, AL_INVALID_VALUE
, done
, "NULL pointer");
24 for(i
= 0;i
< count
;i
++)
26 if(types
[i
] == AL_EVENT_TYPE_BUFFER_COMPLETED_SOFT
)
27 flags
|= EventType_BufferCompleted
;
28 else if(types
[i
] == AL_EVENT_TYPE_SOURCE_STATE_CHANGED_SOFT
)
29 flags
|= EventType_SourceStateChange
;
30 else if(types
[i
] == AL_EVENT_TYPE_ERROR_SOFT
)
31 flags
|= EventType_Error
;
32 else if(types
[i
] == AL_EVENT_TYPE_PERFORMANCE_SOFT
)
33 flags
|= EventType_Performance
;
34 else if(types
[i
] == AL_EVENT_TYPE_DEPRECATED_SOFT
)
35 flags
|= EventType_Deprecated
;
37 SETERR_GOTO(context
, AL_INVALID_ENUM
, done
, "Invalid event type 0x%04x", types
[i
]);
40 almtx_lock(&context
->EventLock
);
43 ALbitfieldSOFT enabledevts
= ATOMIC_LOAD(&context
->EnabledEvts
, almemory_order_relaxed
);
44 while(ATOMIC_COMPARE_EXCHANGE_WEAK(&context
->EnabledEvts
, &enabledevts
, enabledevts
|flags
,
45 almemory_order_acq_rel
, almemory_order_acquire
) == 0)
47 /* enabledevts is (re-)filled with the current value on failure, so
54 ALbitfieldSOFT enabledevts
= ATOMIC_LOAD(&context
->EnabledEvts
, almemory_order_relaxed
);
55 while(ATOMIC_COMPARE_EXCHANGE_WEAK(&context
->EnabledEvts
, &enabledevts
, enabledevts
&~flags
,
56 almemory_order_acq_rel
, almemory_order_acquire
) == 0)
60 almtx_unlock(&context
->EventLock
);
63 ALCcontext_DecRef(context
);
66 AL_API
void AL_APIENTRY
alEventCallbackSOFT(ALEVENTPROCSOFT callback
, void *userParam
)
70 context
= GetContextRef();
73 almtx_lock(&context
->EventLock
);
74 context
->EventCb
= callback
;
75 context
->EventParam
= userParam
;
76 almtx_unlock(&context
->EventLock
);
78 ALCcontext_DecRef(context
);