11 #include <unordered_map>
12 #include <string_view>
20 #include "core/device.h"
21 #include "intrusive_ptr.h"
24 #include "al/eax/x_ram.h"
32 using uint
= unsigned int;
35 struct ALCdevice
: public al::intrusive_ref
<ALCdevice
>, DeviceBase
{
36 /* This lock protects the device state (format, update size, etc) from
37 * being from being changed in multiple threads, or being accessed while
38 * being changed. It's also used to serialize calls to the backend.
41 std::unique_ptr
<BackendBase
> Backend
;
43 ALCuint NumMonoSources
{};
44 ALCuint NumStereoSources
{};
46 // Maximum number of sources that can be created
48 // Maximum number of slots that can be created
49 uint AuxiliaryEffectSlotMax
{};
51 std::string mHrtfName
;
52 std::vector
<std::string
> mHrtfList
;
53 ALCenum mHrtfStatus
{ALC_FALSE
};
55 enum class OutputMode1
: ALCenum
{
58 Stereo
= ALC_STEREO_SOFT
,
59 StereoBasic
= ALC_STEREO_BASIC_SOFT
,
60 Uhj2
= ALC_STEREO_UHJ_SOFT
,
61 Hrtf
= ALC_STEREO_HRTF_SOFT
,
63 X51
= ALC_SURROUND_5_1_SOFT
,
64 X61
= ALC_SURROUND_6_1_SOFT
,
65 X71
= ALC_SURROUND_7_1_SOFT
67 OutputMode1
getOutputMode1() const noexcept
;
69 using OutputMode
= OutputMode1
;
71 std::atomic
<ALCenum
> LastError
{ALC_NO_ERROR
};
73 // Map of Buffers for this device
74 std::mutex BufferLock
;
75 std::vector
<BufferSubList
> BufferList
;
77 // Map of Effects for this device
78 std::mutex EffectLock
;
79 std::vector
<EffectSubList
> EffectList
;
81 // Map of Filters for this device
82 std::mutex FilterLock
;
83 std::vector
<FilterSubList
> FilterList
;
86 ALuint eax_x_ram_free_size
{eax_x_ram_max_size
};
90 std::unordered_map
<ALuint
,std::string
> mBufferNames
;
91 std::unordered_map
<ALuint
,std::string
> mEffectNames
;
92 std::unordered_map
<ALuint
,std::string
> mFilterNames
;
94 std::string mVendorOverride
;
95 std::string mVersionOverride
;
96 std::string mRendererOverride
;
98 ALCdevice(DeviceType type
);
101 void enumerateHrtfs();
103 bool getConfigValueBool(const std::string_view block
, const std::string_view key
, bool def
)
104 { return GetConfigValueBool(mDeviceName
, block
, key
, def
); }
107 inline std::optional
<T
> configValue(const std::string_view block
, const std::string_view key
) = delete;
111 inline std::optional
<std::string
> ALCdevice::configValue(const std::string_view block
, const std::string_view key
)
112 { return ConfigValueStr(mDeviceName
, block
, key
); }
114 inline std::optional
<int> ALCdevice::configValue(const std::string_view block
, const std::string_view key
)
115 { return ConfigValueInt(mDeviceName
, block
, key
); }
117 inline std::optional
<uint
> ALCdevice::configValue(const std::string_view block
, const std::string_view key
)
118 { return ConfigValueUInt(mDeviceName
, block
, key
); }
120 inline std::optional
<float> ALCdevice::configValue(const std::string_view block
, const std::string_view key
)
121 { return ConfigValueFloat(mDeviceName
, block
, key
); }
123 inline std::optional
<bool> ALCdevice::configValue(const std::string_view block
, const std::string_view key
)
124 { return ConfigValueBool(mDeviceName
, block
, key
); }
126 /** Stores the latest ALC device error. */
127 void alcSetError(ALCdevice
*device
, ALCenum errorCode
);