diff options
author | Chris Robinson <[email protected]> | 2023-05-22 02:25:30 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2023-05-22 02:25:30 -0700 |
commit | eca86489e422f00d96ce59a5c53fa45bdcea593e (patch) | |
tree | 023fafac55d3dc6888021fccf444f0e0990f3b83 /examples/alffplay.cpp | |
parent | 586b725cc37345601f01473dcc622241ee80d174 (diff) |
Make the API functions noexcept
Only relevant for C++, but these functions can't throw as it's a C-based API.
Letting the compiler know that helps improve code generation. Extension
callbacks must also not let exceptions leave the callback, or else Bad Things
can happen.
The macro AL_DISABLE_NOEXCEPT may be defined before including the headers to
not mark functions as noexcept, but this should only be done if the caller
can't otherwise be fixed.
Diffstat (limited to 'examples/alffplay.cpp')
-rw-r--r-- | examples/alffplay.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/examples/alffplay.cpp b/examples/alffplay.cpp index ae40a51a..1f02ef70 100644 --- a/examples/alffplay.cpp +++ b/examples/alffplay.cpp @@ -339,14 +339,14 @@ struct AudioState { } static void AL_APIENTRY eventCallbackC(ALenum eventType, ALuint object, ALuint param, - ALsizei length, const ALchar *message, void *userParam) + ALsizei length, const ALchar *message, void *userParam) noexcept { static_cast<AudioState*>(userParam)->eventCallback(eventType, object, param, length, message); } void eventCallback(ALenum eventType, ALuint object, ALuint param, ALsizei length, - const ALchar *message); + const ALchar *message) noexcept; - static ALsizei AL_APIENTRY bufferCallbackC(void *userptr, void *data, ALsizei size) + static ALsizei AL_APIENTRY bufferCallbackC(void *userptr, void *data, ALsizei size) noexcept { return static_cast<AudioState*>(userptr)->bufferCallback(data, size); } - ALsizei bufferCallback(void *data, ALsizei size); + ALsizei bufferCallback(void *data, ALsizei size) noexcept; nanoseconds getClockNoLock(); nanoseconds getClock() @@ -840,7 +840,7 @@ bool AudioState::readAudio(int sample_skip) void AL_APIENTRY AudioState::eventCallback(ALenum eventType, ALuint object, ALuint param, - ALsizei length, const ALchar *message) + ALsizei length, const ALchar *message) noexcept { if(eventType == AL_EVENT_TYPE_BUFFER_COMPLETED_SOFT) { @@ -878,7 +878,7 @@ void AL_APIENTRY AudioState::eventCallback(ALenum eventType, ALuint object, ALui } } -ALsizei AudioState::bufferCallback(void *data, ALsizei size) +ALsizei AudioState::bufferCallback(void *data, ALsizei size) noexcept { ALsizei got{0}; |