From c03603b58d4cf6a25d36bca00305970bc9f163b4 Mon Sep 17 00:00:00 2001 From: MathiusD Date: Sun, 26 Nov 2023 03:33:00 +0100 Subject: Add query fonction in ALC_SOFT_system_events unreleased extension (#938) * feat(ALC_SOFT_system_events): Add alcEventIsSupportedSOFT method in ALC_SOFT_system_events unreleased extension The purpose of this addition (to my collection) are allow to retrieve which events are supported and if events are fully supported or if some case isn't managed for some reason For exemple only some backends provide system events: * pipewire -> Full support of extension * wasapi -> Full support of extension * pulseaudio -> Support of add and remove devices events only * coreaudio -> Support of default device change only * feat(ALC_SOFT_system_events): Fix typo in alext.h Cf following review : https://github.com/kcat/openal-soft/pull/938#discussion_r1404509828 * feat(ALC_SOFT_system_events): Remove ALC_EVENT_NOT_SUPPORTED_SOFT token Cf following discussions between this comment : https://github.com/kcat/openal-soft/pull/938#issuecomment-1825876452 to this comment : https://github.com/kcat/openal-soft/pull/938#issuecomment-1826419406 --- alc/events.cpp | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) (limited to 'alc/events.cpp') diff --git a/alc/events.cpp b/alc/events.cpp index a80faf8a..1010a338 100644 --- a/alc/events.cpp +++ b/alc/events.cpp @@ -3,8 +3,6 @@ #include "events.h" -#include - #include "alspan.h" #include "core/logging.h" #include "device.h" @@ -12,17 +10,6 @@ namespace { -std::optional GetEventType(ALCenum type) -{ - switch(type) - { - case ALC_EVENT_TYPE_DEFAULT_DEVICE_CHANGED_SOFT: return alc::EventType::DefaultDeviceChanged; - case ALC_EVENT_TYPE_DEVICE_ADDED_SOFT: return alc::EventType::DeviceAdded; - case ALC_EVENT_TYPE_DEVICE_REMOVED_SOFT: return alc::EventType::DeviceRemoved; - } - return std::nullopt; -} - ALCenum EnumFromEventType(const alc::EventType type) { switch(type) @@ -39,6 +26,17 @@ ALCenum EnumFromEventType(const alc::EventType type) namespace alc { +std::optional GetEventType(ALCenum type) +{ + switch(type) + { + case ALC_EVENT_TYPE_DEFAULT_DEVICE_CHANGED_SOFT: return alc::EventType::DefaultDeviceChanged; + case ALC_EVENT_TYPE_DEVICE_ADDED_SOFT: return alc::EventType::DeviceAdded; + case ALC_EVENT_TYPE_DEVICE_REMOVED_SOFT: return alc::EventType::DeviceRemoved; + } + return std::nullopt; +} + void Event(EventType eventType, DeviceType deviceType, ALCdevice *device, std::string_view message) noexcept { auto eventlock = std::unique_lock{EventMutex}; @@ -73,7 +71,7 @@ FORCE_ALIGN ALCboolean ALC_APIENTRY alcEventControlSOFT(ALCsizei count, const AL alc::EventBitSet eventSet{0}; for(ALCenum type : al::span{events, static_cast(count)}) { - auto etype = GetEventType(type); + auto etype = alc::GetEventType(type); if(!etype) { WARN("Invalid event type: 0x%04x\n", type); -- cgit v1.2.3