11 #include <unordered_map>
20 #include "alnumeric.h"
21 #include "core/device.h"
22 #include "inprogext.h"
23 #include "intrusive_ptr.h"
26 #include "al/eax/x_ram.h"
37 using uint
= unsigned int;
40 struct ALCdevice
: public al::intrusive_ref
<ALCdevice
>, DeviceBase
{
41 /* This lock protects the device state (format, update size, etc) from
42 * being from being changed in multiple threads, or being accessed while
43 * being changed. It's also used to serialize calls to the backend.
46 std::unique_ptr
<BackendBase
> Backend
;
48 ALCuint NumMonoSources
{};
49 ALCuint NumStereoSources
{};
51 // Maximum number of sources that can be created
53 // Maximum number of slots that can be created
54 uint AuxiliaryEffectSlotMax
{};
56 std::string mHrtfName
;
57 std::vector
<std::string
> mHrtfList
;
58 ALCenum mHrtfStatus
{ALC_FALSE
};
60 enum class OutputMode1
: ALCenum
{
63 Stereo
= ALC_STEREO_SOFT
,
64 StereoBasic
= ALC_STEREO_BASIC_SOFT
,
65 Uhj2
= ALC_STEREO_UHJ_SOFT
,
66 Hrtf
= ALC_STEREO_HRTF_SOFT
,
68 X51
= ALC_SURROUND_5_1_SOFT
,
69 X61
= ALC_SURROUND_6_1_SOFT
,
70 X71
= ALC_SURROUND_7_1_SOFT
72 OutputMode1
getOutputMode1() const noexcept
;
74 using OutputMode
= OutputMode1
;
76 std::atomic
<ALCenum
> LastError
{ALC_NO_ERROR
};
78 // Map of Buffers for this device
79 std::mutex BufferLock
;
80 std::vector
<BufferSubList
> BufferList
;
82 // Map of Effects for this device
83 std::mutex EffectLock
;
84 std::vector
<EffectSubList
> EffectList
;
86 // Map of Filters for this device
87 std::mutex FilterLock
;
88 std::vector
<FilterSubList
> FilterList
;
91 ALuint eax_x_ram_free_size
{eax_x_ram_max_size
};
95 std::unordered_map
<ALuint
,std::string
> mBufferNames
;
96 std::unordered_map
<ALuint
,std::string
> mEffectNames
;
97 std::unordered_map
<ALuint
,std::string
> mFilterNames
;
99 ALCdevice(DeviceType type
);
102 void enumerateHrtfs();
104 bool getConfigValueBool(const std::string_view block
, const std::string_view key
, bool def
)
105 { return GetConfigValueBool(DeviceName
, block
, key
, def
); }
108 inline std::optional
<T
> configValue(const std::string_view block
, const std::string_view key
) = delete;
112 inline std::optional
<std::string
> ALCdevice::configValue(const std::string_view block
, const std::string_view key
)
113 { return ConfigValueStr(DeviceName
, block
, key
); }
115 inline std::optional
<int> ALCdevice::configValue(const std::string_view block
, const std::string_view key
)
116 { return ConfigValueInt(DeviceName
, block
, key
); }
118 inline std::optional
<uint
> ALCdevice::configValue(const std::string_view block
, const std::string_view key
)
119 { return ConfigValueUInt(DeviceName
, block
, key
); }
121 inline std::optional
<float> ALCdevice::configValue(const std::string_view block
, const std::string_view key
)
122 { return ConfigValueFloat(DeviceName
, block
, key
); }
124 inline std::optional
<bool> ALCdevice::configValue(const std::string_view block
, const std::string_view key
)
125 { return ConfigValueBool(DeviceName
, block
, key
); }
127 /** Stores the latest ALC device error. */
128 void alcSetError(ALCdevice
*device
, ALCenum errorCode
);