aboutsummaryrefslogtreecommitdiffstats
path: root/alc/events.h
blob: 3f53ec76265be90edb00b4ac568c1578e68603e5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#ifndef ALC_EVENTS_H
#define ALC_EVENTS_H

#include "inprogext.h"
#include "opthelpers.h"

#include <bitset>
#include <mutex>
#include <optional>
#include <string_view>


namespace alc {

enum class EventType : uint8_t {
    DefaultDeviceChanged,
    DeviceAdded,
    DeviceRemoved,

    Count
};

std::optional<alc::EventType> GetEventType(ALCenum type);

enum class EventSupport : ALCenum {
    FullSupport = ALC_EVENT_SUPPORTED_SOFT,
    NoSupport = ALC_EVENT_NOT_SUPPORTED_SOFT,
};

enum class DeviceType : ALCenum {
    Playback = ALC_PLAYBACK_DEVICE_SOFT,
    Capture = ALC_CAPTURE_DEVICE_SOFT,
};

using EventBitSet = std::bitset<al::to_underlying(EventType::Count)>;
inline EventBitSet EventsEnabled{0};

inline std::mutex EventMutex;

inline ALCEVENTPROCTYPESOFT EventCallback{};
inline void *EventUserPtr{};

void Event(EventType eventType, DeviceType deviceType, ALCdevice *device, std::string_view message) noexcept;

inline void Event(EventType eventType, DeviceType deviceType, std::string_view message) noexcept
{ Event(eventType, deviceType, nullptr, message); }

} // namespace alc

#endif /* ALC_EVENTS_H */