Add a SIGTRAP for when alGetError is called without a context

This commit is contained in:
Chris Robinson
2012-04-24 21:41:01 -07:00
parent 3e49e79140
commit 58e3dc3d52
+27 -15
View File
@@ -28,21 +28,6 @@
ALboolean TrapALError = AL_FALSE;
AL_API ALenum AL_APIENTRY alGetError(void)
{
ALCcontext *Context;
ALenum errorCode;
Context = GetContextRef();
if(!Context) return AL_INVALID_OPERATION;
errorCode = ExchangeInt(&Context->LastError, AL_NO_ERROR);
ALCcontext_DecRef(Context);
return errorCode;
}
ALvoid alSetError(ALCcontext *Context, ALenum errorCode)
{
if(TrapALError)
@@ -57,3 +42,30 @@ ALvoid alSetError(ALCcontext *Context, ALenum errorCode)
}
CompExchangeInt(&Context->LastError, AL_NO_ERROR, errorCode);
}
AL_API ALenum AL_APIENTRY alGetError(void)
{
ALCcontext *Context;
ALenum errorCode;
Context = GetContextRef();
if(!Context)
{
if(TrapALError)
{
#ifdef _WIN32
if(IsDebuggerPresent())
DebugBreak();
#elif defined(SIGTRAP)
raise(SIGTRAP);
#endif
}
return AL_INVALID_OPERATION;
}
errorCode = ExchangeInt(&Context->LastError, AL_NO_ERROR);
ALCcontext_DecRef(Context);
return errorCode;
}