aboutsummaryrefslogtreecommitdiffstats
path: root/alc/alc.cpp
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2023-07-24 12:46:34 -0700
committerChris Robinson <[email protected]>2023-07-24 12:46:34 -0700
commit8b3a9b527d87009f86ed0b4eb6c33a9e8dfc069b (patch)
treee0958e43400c5b0e8a0998c74ca533e2d4462dfa /alc/alc.cpp
parent4925439fe765873d1fed9c007c8944b9bbeb0e85 (diff)
Catch exceptions from constructing ALCcontexts
Diffstat (limited to 'alc/alc.cpp')
-rw-r--r--alc/alc.cpp16
1 files changed, 15 insertions, 1 deletions
diff --git a/alc/alc.cpp b/alc/alc.cpp
index d36f1891..82f3ec4b 100644
--- a/alc/alc.cpp
+++ b/alc/alc.cpp
@@ -2660,7 +2660,21 @@ ALC_API ALCcontext* ALC_APIENTRY alcCreateContext(ALCdevice *device, const ALCin
}
}
- ContextRef context{new ALCcontext{dev, ctxflags}};
+ ContextRef context{[](auto&& ...args) -> ContextRef
+ {
+ try {
+ return ContextRef{new ALCcontext{std::forward<decltype(args)>(args)...}};
+ }
+ catch(std::exception& e) {
+ ERR("Failed to create ALCcontext: %s\n", e.what());
+ return ContextRef{};
+ }
+ }(dev, ctxflags)};
+ if(!context)
+ {
+ alcSetError(dev.get(), ALC_OUT_OF_MEMORY);
+ return nullptr;
+ }
context->init();
if(auto volopt = dev->configValue<float>(nullptr, "volume-adjust"))