diff options
author | Chris Robinson <[email protected]> | 2020-04-10 15:11:40 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2020-04-10 15:12:57 -0700 |
commit | f7380a44d4c5c6345602db8630ae7bbd971cac1d (patch) | |
tree | 9034ad41ed0275498c7c712b9fe4cff8f5c725ee /al/filter.cpp | |
parent | 611a0155cd4bbe588918b07a219cc830c77691c3 (diff) |
Use a common base for a couple exceptions
Diffstat (limited to 'al/filter.cpp')
-rw-r--r-- | al/filter.cpp | 32 |
1 files changed, 8 insertions, 24 deletions
diff --git a/al/filter.cpp b/al/filter.cpp index ecbdc7f6..a861c8cd 100644 --- a/al/filter.cpp +++ b/al/filter.cpp @@ -47,33 +47,17 @@ namespace { -class filter_exception final : public std::exception { - std::string mMessage; - ALenum mErrorCode; - +class filter_exception final : public al::base_exception { public: - filter_exception(ALenum code, const char *msg, ...) ALEXCPT_FORMAT(printf, 3,4); - - const char *what() const noexcept override { return mMessage.c_str(); } - ALenum errorCode() const noexcept { return mErrorCode; } -}; - -filter_exception::filter_exception(ALenum code, const char *msg, ...) : mErrorCode{code} -{ - std::va_list args, args2; - va_start(args, msg); - va_copy(args2, args); - int msglen{std::vsnprintf(nullptr, 0, msg, args)}; - if LIKELY(msglen > 0) + [[gnu::format(printf, 3, 4)]] + filter_exception(ALenum code, const char *msg, ...) : base_exception{code} { - mMessage.resize(static_cast<size_t>(msglen)+1); - std::vsnprintf(&mMessage[0], mMessage.length(), msg, args2); - mMessage.pop_back(); + va_list args; + va_start(args, msg); + setMessage(msg, args); + va_end(args); } - va_end(args2); - va_end(args); -} - +}; #define FILTER_MIN_GAIN 0.0f #define FILTER_MAX_GAIN 4.0f /* +12dB */ |