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/events.h | |
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/events.h')
-rw-r--r-- | alc/events.h | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/alc/events.h b/alc/events.h new file mode 100644 index 00000000..51f32e57 --- /dev/null +++ b/alc/events.h @@ -0,0 +1,36 @@ +#ifndef ALC_EVENTS_H +#define ALC_EVENTS_H + +#include "inprogext.h" +#include "opthelpers.h" + +#include <bitset> +#include <mutex> +#include <string_view> + + +namespace alc { + +enum class EventType : uint8_t { + DefaultDeviceChanged, + DeviceAdded, + DeviceRemoved, + + Count +}; + +inline std::bitset<al::to_underlying(EventType::Count)> EventsEnabled{0}; + +inline std::mutex EventMutex; + +inline ALCEVENTPROCTYPESOFT EventCallback{}; +inline void *EventUserPtr{}; + +void Event(ALCenum eventType, ALCdevice *device, std::string_view message) noexcept; + +inline void Event(ALCenum eventType, std::string_view message) noexcept +{ Event(eventType, nullptr, message); } + +} // namespace alc + +#endif /* ALC_EVENTS_H */ |