MCPcopy Create free account
hub / github.com/crownengine/crown / setError

Method setError

3rdparty/openal/al/error.cpp:50–93  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

48bool TrapALError{false};
49
50void ALCcontext::setError(ALenum errorCode, const char *msg, ...)
51{
52 auto message = al::vector<char>(256);
53
54 va_list args, args2;
55 va_start(args, msg);
56 va_copy(args2, args);
57 int msglen{std::vsnprintf(message.data(), message.size(), msg, args)};
58 if(msglen >= 0 && static_cast<size_t>(msglen) >= message.size())
59 {
60 message.resize(static_cast<size_t>(msglen) + 1u);
61 msglen = std::vsnprintf(message.data(), message.size(), msg, args2);
62 }
63 va_end(args2);
64 va_end(args);
65
66 if(msglen >= 0) msg = message.data();
67 else msg = "<internal error constructing message>";
68 msglen = static_cast<int>(strlen(msg));
69
70 WARN("Error generated on context %p, code 0x%04x, \"%s\"\n",
71 decltype(std::declval<void*>()){this}, errorCode, msg);
72 if(TrapALError)
73 {
74#ifdef _WIN32
75 /* DebugBreak will cause an exception if there is no debugger */
76 if(IsDebuggerPresent())
77 DebugBreak();
78#elif defined(SIGTRAP)
79 raise(SIGTRAP);
80#endif
81 }
82
83 ALenum curerr{AL_NO_ERROR};
84 mLastError.compare_exchange_strong(curerr, errorCode);
85 if((mEnabledEvts.load(std::memory_order_relaxed)&EventType_Error))
86 {
87 std::lock_guard<std::mutex> _{mEventCbLock};
88 ALbitfieldSOFT enabledevts{mEnabledEvts.load(std::memory_order_relaxed)};
89 if((enabledevts&EventType_Error) && mEventCb)
90 (*mEventCb)(AL_EVENT_TYPE_ERROR_SOFT, 0, static_cast<ALuint>(errorCode), msglen, msg,
91 mEventParam);
92 }
93}
94
95AL_API ALenum AL_APIENTRY alGetError(void)
96START_API_FUNC

Callers 15

state.cppFile · 0.80
AL_APIENTRY alGetStringFunction · 0.80
ALlowpass_setParamiFunction · 0.80
ALlowpass_setParamivFunction · 0.80
ALlowpass_setParamfFunction · 0.80
ALlowpass_getParamiFunction · 0.80
ALlowpass_getParamivFunction · 0.80
ALlowpass_getParamfFunction · 0.80

Calls 6

strlenFunction · 0.85
vsnprintfFunction · 0.50
dataMethod · 0.45
sizeMethod · 0.45
resizeMethod · 0.45
loadMethod · 0.45

Tested by

no test coverage detected