events.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #ifndef ALC_EVENTS_H
  2. #define ALC_EVENTS_H
  3. #include "inprogext.h"
  4. #include "opthelpers.h"
  5. #include <bitset>
  6. #include <mutex>
  7. #include <optional>
  8. #include <string_view>
  9. namespace alc {
  10. enum class EventType : uint8_t {
  11. DefaultDeviceChanged,
  12. DeviceAdded,
  13. DeviceRemoved,
  14. Count
  15. };
  16. std::optional<alc::EventType> GetEventType(ALCenum type);
  17. enum class EventSupport : ALCenum {
  18. FullSupport = ALC_EVENT_SUPPORTED_SOFT,
  19. NoSupport = ALC_EVENT_NOT_SUPPORTED_SOFT,
  20. };
  21. enum class DeviceType : ALCenum {
  22. Playback = ALC_PLAYBACK_DEVICE_SOFT,
  23. Capture = ALC_CAPTURE_DEVICE_SOFT,
  24. };
  25. using EventBitSet = std::bitset<al::to_underlying(EventType::Count)>;
  26. inline EventBitSet EventsEnabled{0};
  27. inline std::mutex EventMutex;
  28. inline ALCEVENTPROCTYPESOFT EventCallback{};
  29. inline void *EventUserPtr{};
  30. void Event(EventType eventType, DeviceType deviceType, ALCdevice *device, std::string_view message) noexcept;
  31. inline void Event(EventType eventType, DeviceType deviceType, std::string_view message) noexcept
  32. { Event(eventType, deviceType, nullptr, message); }
  33. } // namespace alc
  34. #endif /* ALC_EVENTS_H */