zenilib  0.5.3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
alError.c
Go to the documentation of this file.
1 
21 #include "config.h"
22 
23 #include <signal.h>
24 
25 #include "alMain.h"
26 #include "AL/alc.h"
27 #include "alError.h"
28 
30 
31 ALvoid alSetError(ALCcontext *Context, ALenum errorCode)
32 {
33  if(TrapALError)
34  {
35 #ifdef _WIN32
36  /* DebugBreak will cause an exception if there is no debugger */
37  if(IsDebuggerPresent())
38  DebugBreak();
39 #elif defined(SIGTRAP)
40  raise(SIGTRAP);
41 #endif
42  }
43  CompExchangeInt(&Context->LastError, AL_NO_ERROR, errorCode);
44 }
45 
47 {
48  ALCcontext *Context;
49  ALenum errorCode;
50 
51  Context = GetContextRef();
52  if(!Context)
53  {
54  if(TrapALError)
55  {
56 #ifdef _WIN32
57  if(IsDebuggerPresent())
58  DebugBreak();
59 #elif defined(SIGTRAP)
60  raise(SIGTRAP);
61 #endif
62  }
63  return AL_INVALID_OPERATION;
64  }
65 
66  errorCode = ExchangeInt(&Context->LastError, AL_NO_ERROR);
67 
68  ALCcontext_DecRef(Context);
69 
70  return errorCode;
71 }
#define AL_APIENTRY
Definition: al.h:21
void ALvoid
Definition: al.h:74
AL_API ALenum AL_APIENTRY alGetError(void)
Definition: alError.c:46
#define AL_FALSE
Definition: al.h:83
ALCcontext * GetContextRef(void)
Definition: ALc.c:1999
int ALenum
Definition: al.h:65
#define AL_API
Definition: al.h:14
ALenum LastError
Definition: alMain.h:684
void ALCcontext_DecRef(ALCcontext *context)
Definition: ALc.c:1949
ALboolean TrapALError
Definition: alError.c:29
char ALboolean
Definition: al.h:38
ALvoid alSetError(ALCcontext *Context, ALenum errorCode)
Definition: alError.c:31
#define AL_NO_ERROR
Definition: al.h:364
#define AL_INVALID_OPERATION
Definition: al.h:376