~ubuntu-branches/ubuntu/vivid/openal-soft/vivid

« back to all changes in this revision

Viewing changes to OpenAL32/alError.c

  • Committer: Package Import Robot
  • Author(s): Andres Mejia
  • Date: 2012-04-01 16:19:00 UTC
  • mfrom: (0.2.9)
  • Revision ID: package-import@ubuntu.com-20120401161900-4dy81gsmc70tvon2
Tags: 1:1.14-1
* New upstream release.
* Add CPPFLAGS to CFLAGS. (Closes: #666095)
* Enable new sndio support.

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
 
21
21
#include "config.h"
22
22
 
 
23
#include <signal.h>
 
24
 
23
25
#include "alMain.h"
24
26
#include "AL/alc.h"
25
27
#include "alError.h"
26
28
 
27
 
AL_API ALenum AL_APIENTRY alGetError(ALvoid)
 
29
ALboolean TrapALError = AL_FALSE;
 
30
 
 
31
AL_API ALenum AL_APIENTRY alGetError(void)
28
32
{
29
33
    ALCcontext *Context;
30
34
    ALenum errorCode;
31
35
 
32
 
    Context = GetContextSuspended();
 
36
    Context = GetContextRef();
33
37
    if(!Context) return AL_INVALID_OPERATION;
34
38
 
35
 
    errorCode = Context->LastError;
36
 
    Context->LastError = AL_NO_ERROR;
 
39
    errorCode = ExchangeInt(&Context->LastError, AL_NO_ERROR);
37
40
 
38
 
    ProcessContext(Context);
 
41
    ALCcontext_DecRef(Context);
39
42
 
40
43
    return errorCode;
41
44
}
42
45
 
43
46
ALvoid alSetError(ALCcontext *Context, ALenum errorCode)
44
47
{
45
 
    if(Context->LastError == AL_NO_ERROR)
46
 
        Context->LastError = errorCode;
 
48
    if(TrapALError)
 
49
    {
 
50
#ifdef _WIN32
 
51
        /* DebugBreak will cause an exception if there is no debugger */
 
52
        if(IsDebuggerPresent())
 
53
            DebugBreak();
 
54
#elif defined(SIGTRAP)
 
55
        raise(SIGTRAP);
 
56
#endif
 
57
    }
 
58
    CompExchangeInt(&Context->LastError, AL_NO_ERROR, errorCode);
47
59
}