diff options
author | Chris Robinson <[email protected]> | 2023-05-30 21:16:41 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2023-05-30 21:16:41 -0700 |
commit | 517bb94c0953de768f6aacca45456fd63bb2c96d (patch) | |
tree | 28852929ea0c61e1e7ad6f20233c861c5ae3f040 /alc/alc.cpp | |
parent | 2e75909ce90027267775d53e997d4936d6ef31a5 (diff) |
Add a callback to report system device changes
Devices being added or removed, or the default device changing. Not all
backends report this (none do currently), but it'll be supported where it can.
Diffstat (limited to 'alc/alc.cpp')
-rw-r--r-- | alc/alc.cpp | 54 |
1 files changed, 30 insertions, 24 deletions
diff --git a/alc/alc.cpp b/alc/alc.cpp index 88aa73c5..c5d4b9d3 100644 --- a/alc/alc.cpp +++ b/alc/alc.cpp @@ -616,6 +616,9 @@ const struct { DECL(alPushDebugGroupDirectEXT), DECL(alPopDebugGroupDirectEXT), DECL(alGetDebugMessageLogDirectEXT), + + DECL(alcEventControlSOFT), + DECL(alcEventCallbackSOFT), #ifdef ALSOFT_EAX }, eaxFunctions[] = { DECL(EAXGet), @@ -1174,7 +1177,8 @@ constexpr ALCchar alcNoDeviceExtList[] = "ALC_EXT_thread_local_context " "ALC_SOFT_loopback " "ALC_SOFT_loopback_bformat " - "ALC_SOFT_reopen_device"; + "ALC_SOFT_reopen_device " + "ALC_SOFTX_system_events"; constexpr ALCchar alcExtensionList[] = "ALC_ENUMERATE_ALL_EXT " "ALC_ENUMERATION_EXT " @@ -1192,7 +1196,8 @@ constexpr ALCchar alcExtensionList[] = "ALC_SOFT_output_limiter " "ALC_SOFT_output_mode " "ALC_SOFT_pause_device " - "ALC_SOFT_reopen_device"; + "ALC_SOFT_reopen_device " + "ALC_SOFTX_system_events"; constexpr int alcMajorVersion{1}; constexpr int alcMinorVersion{1}; @@ -1815,28 +1820,6 @@ const std::array<InputRemixMap,1> X71Downmix{{ }}; -/** Stores the latest ALC device error. */ -void alcSetError(ALCdevice *device, ALCenum errorCode) -{ - WARN("Error generated on device %p, code 0x%04x\n", voidp{device}, errorCode); - if(TrapALCError) - { -#ifdef _WIN32 - /* DebugBreak() will cause an exception if there is no debugger */ - if(IsDebuggerPresent()) - DebugBreak(); -#elif defined(SIGTRAP) - raise(SIGTRAP); -#endif - } - - if(device) - device->LastError.store(errorCode); - else - LastNullDeviceError.store(errorCode); -} - - std::unique_ptr<Compressor> CreateDeviceLimiter(const ALCdevice *device, const float threshold) { static constexpr bool AutoKnee{true}; @@ -2754,6 +2737,25 @@ ContextRef GetContextRef(void) return ContextRef{context}; } +void alcSetError(ALCdevice *device, ALCenum errorCode) +{ + WARN("Error generated on device %p, code 0x%04x\n", voidp{device}, errorCode); + if(TrapALCError) + { +#ifdef _WIN32 + /* DebugBreak() will cause an exception if there is no debugger */ + if(IsDebuggerPresent()) + DebugBreak(); +#elif defined(SIGTRAP) + raise(SIGTRAP); +#endif + } + + if(device) + device->LastError.store(errorCode); + else + LastNullDeviceError.store(errorCode); +} /************************************************ * Standard ALC functions @@ -3436,6 +3438,8 @@ ALC_API ALCvoid* ALC_APIENTRY alcGetProcAddress(ALCdevice *device, const ALCchar alcSetError(dev.get(), ALC_INVALID_VALUE); return nullptr; } + + InitConfig(); #ifdef ALSOFT_EAX if(eax_g_is_enabled) { @@ -3463,6 +3467,8 @@ ALC_API ALCenum ALC_APIENTRY alcGetEnumValue(ALCdevice *device, const ALCchar *e alcSetError(dev.get(), ALC_INVALID_VALUE); return 0; } + + InitConfig(); #ifdef ALSOFT_EAX if(eax_g_is_enabled) { |