mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-14 16:14:38 +00:00
openal-soft updates
This commit is contained in:
parent
7f674a59c6
commit
2bc1148963
149 changed files with 22293 additions and 16887 deletions
|
|
@ -21,6 +21,7 @@
|
|||
#include "config.h"
|
||||
|
||||
#include <signal.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#ifdef HAVE_WINDOWS_H
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
|
|
@ -33,9 +34,32 @@
|
|||
|
||||
ALboolean TrapALError = AL_FALSE;
|
||||
|
||||
ALvoid alSetError(ALCcontext *Context, ALenum errorCode)
|
||||
void alSetError(ALCcontext *context, ALenum errorCode, const char *msg, ...)
|
||||
{
|
||||
ALenum curerr = AL_NO_ERROR;
|
||||
char message[1024] = { 0 };
|
||||
va_list args;
|
||||
int msglen;
|
||||
|
||||
va_start(args, msg);
|
||||
msglen = vsnprintf(message, sizeof(message), msg, args);
|
||||
va_end(args);
|
||||
|
||||
if(msglen < 0 || (size_t)msglen >= sizeof(message))
|
||||
{
|
||||
message[sizeof(message)-1] = 0;
|
||||
msglen = (int)strlen(message);
|
||||
}
|
||||
if(msglen > 0)
|
||||
msg = message;
|
||||
else
|
||||
{
|
||||
msg = "<internal error constructing message>";
|
||||
msglen = (int)strlen(msg);
|
||||
}
|
||||
|
||||
WARN("Error generated on context %p, code 0x%04x, \"%s\"\n",
|
||||
context, errorCode, message);
|
||||
if(TrapALError)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
|
|
@ -46,17 +70,30 @@ ALvoid alSetError(ALCcontext *Context, ALenum errorCode)
|
|||
raise(SIGTRAP);
|
||||
#endif
|
||||
}
|
||||
ATOMIC_COMPARE_EXCHANGE_STRONG(ALenum, &Context->LastError, &curerr, errorCode);
|
||||
|
||||
ATOMIC_COMPARE_EXCHANGE_STRONG_SEQ(&context->LastError, &curerr, errorCode);
|
||||
if((ATOMIC_LOAD(&context->EnabledEvts, almemory_order_relaxed)&EventType_Error))
|
||||
{
|
||||
ALbitfieldSOFT enabledevts;
|
||||
almtx_lock(&context->EventCbLock);
|
||||
enabledevts = ATOMIC_LOAD(&context->EnabledEvts, almemory_order_relaxed);
|
||||
if((enabledevts&EventType_Error) && context->EventCb)
|
||||
(*context->EventCb)(AL_EVENT_TYPE_ERROR_SOFT, 0, errorCode, msglen, msg,
|
||||
context->EventParam);
|
||||
almtx_unlock(&context->EventCbLock);
|
||||
}
|
||||
}
|
||||
|
||||
AL_API ALenum AL_APIENTRY alGetError(void)
|
||||
{
|
||||
ALCcontext *Context;
|
||||
ALCcontext *context;
|
||||
ALenum errorCode;
|
||||
|
||||
Context = GetContextRef();
|
||||
if(!Context)
|
||||
context = GetContextRef();
|
||||
if(!context)
|
||||
{
|
||||
const ALenum deferror = AL_INVALID_OPERATION;
|
||||
WARN("Querying error state on null context (implicitly 0x%04x)\n", deferror);
|
||||
if(TrapALError)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
|
|
@ -66,12 +103,11 @@ AL_API ALenum AL_APIENTRY alGetError(void)
|
|||
raise(SIGTRAP);
|
||||
#endif
|
||||
}
|
||||
return AL_INVALID_OPERATION;
|
||||
return deferror;
|
||||
}
|
||||
|
||||
errorCode = ATOMIC_EXCHANGE(ALenum, &Context->LastError, AL_NO_ERROR);
|
||||
|
||||
ALCcontext_DecRef(Context);
|
||||
errorCode = ATOMIC_EXCHANGE_SEQ(&context->LastError, AL_NO_ERROR);
|
||||
|
||||
ALCcontext_DecRef(context);
|
||||
return errorCode;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue