9 #include <unordered_map>
10 #include <string_view>
18 #include "core/device.h"
19 #include "intrusive_ptr.h"
22 #include "al/eax/x_ram.h"
30 using uint
= unsigned int;
33 struct ALCdevice
: public al::intrusive_ref
<ALCdevice
>, DeviceBase
{
34 /* This lock protects the device state (format, update size, etc) from
35 * being from being changed in multiple threads, or being accessed while
36 * being changed. It's also used to serialize calls to the backend.
39 std::unique_ptr
<BackendBase
> Backend
;
41 ALCuint NumMonoSources
{};
42 ALCuint NumStereoSources
{};
44 // Maximum number of sources that can be created
46 // Maximum number of slots that can be created
47 uint AuxiliaryEffectSlotMax
{};
49 std::string mHrtfName
;
50 std::vector
<std::string
> mHrtfList
;
51 ALCenum mHrtfStatus
{ALC_FALSE
};
53 enum class OutputMode1
: ALCenum
{
56 Stereo
= ALC_STEREO_SOFT
,
57 StereoBasic
= ALC_STEREO_BASIC_SOFT
,
58 Uhj2
= ALC_STEREO_UHJ_SOFT
,
59 Hrtf
= ALC_STEREO_HRTF_SOFT
,
61 X51
= ALC_SURROUND_5_1_SOFT
,
62 X61
= ALC_SURROUND_6_1_SOFT
,
63 X71
= ALC_SURROUND_7_1_SOFT
65 OutputMode1
getOutputMode1() const noexcept
;
67 using OutputMode
= OutputMode1
;
69 std::atomic
<ALCenum
> LastError
{ALC_NO_ERROR
};
71 // Map of Buffers for this device
72 std::mutex BufferLock
;
73 std::vector
<BufferSubList
> BufferList
;
75 // Map of Effects for this device
76 std::mutex EffectLock
;
77 std::vector
<EffectSubList
> EffectList
;
79 // Map of Filters for this device
80 std::mutex FilterLock
;
81 std::vector
<FilterSubList
> FilterList
;
84 ALuint eax_x_ram_free_size
{eax_x_ram_max_size
};
88 std::unordered_map
<ALuint
,std::string
> mBufferNames
;
89 std::unordered_map
<ALuint
,std::string
> mEffectNames
;
90 std::unordered_map
<ALuint
,std::string
> mFilterNames
;
92 std::string mVendorOverride
;
93 std::string mVersionOverride
;
94 std::string mRendererOverride
;
96 ALCdevice(DeviceType type
);
99 void enumerateHrtfs();
101 bool getConfigValueBool(const std::string_view block
, const std::string_view key
, bool def
)
102 { return GetConfigValueBool(mDeviceName
, block
, key
, def
); }
105 inline std::optional
<T
> configValue(const std::string_view block
, const std::string_view key
) = delete;
109 inline std::optional
<std::string
> ALCdevice::configValue(const std::string_view block
, const std::string_view key
)
110 { return ConfigValueStr(mDeviceName
, block
, key
); }
112 inline std::optional
<int> ALCdevice::configValue(const std::string_view block
, const std::string_view key
)
113 { return ConfigValueInt(mDeviceName
, block
, key
); }
115 inline std::optional
<uint
> ALCdevice::configValue(const std::string_view block
, const std::string_view key
)
116 { return ConfigValueUInt(mDeviceName
, block
, key
); }
118 inline std::optional
<float> ALCdevice::configValue(const std::string_view block
, const std::string_view key
)
119 { return ConfigValueFloat(mDeviceName
, block
, key
); }
121 inline std::optional
<bool> ALCdevice::configValue(const std::string_view block
, const std::string_view key
)
122 { return ConfigValueBool(mDeviceName
, block
, key
); }
124 /** Stores the latest ALC device error. */
125 void alcSetError(ALCdevice
*device
, ALCenum errorCode
);