10 #include "al/effect.h"
11 #include "al/filter.h"
14 #include "backends/base.h"
15 #include "core/bformatdec.h"
16 #include "core/bs2b.h"
17 #include "core/front_stablizer.h"
18 #include "core/hrtf.h"
19 #include "core/logging.h"
20 #include "core/mastering.h"
21 #include "core/uhjfilter.h"
31 ALCdevice::ALCdevice(DeviceType type
) : DeviceBase
{type
}
34 ALCdevice::~ALCdevice()
36 TRACE("Freeing device %p\n", voidp
{this});
40 size_t count
{std::accumulate(BufferList
.cbegin(), BufferList
.cend(), 0_uz
,
41 [](size_t cur
, const BufferSubList
&sublist
) noexcept
-> size_t
42 { return cur
+ static_cast<uint
>(al::popcount(~sublist
.FreeMask
)); })};
44 WARN("%zu Buffer%s not deleted\n", count
, (count
==1)?"":"s");
46 count
= std::accumulate(EffectList
.cbegin(), EffectList
.cend(), 0_uz
,
47 [](size_t cur
, const EffectSubList
&sublist
) noexcept
-> size_t
48 { return cur
+ static_cast<uint
>(al::popcount(~sublist
.FreeMask
)); });
50 WARN("%zu Effect%s not deleted\n", count
, (count
==1)?"":"s");
52 count
= std::accumulate(FilterList
.cbegin(), FilterList
.cend(), 0_uz
,
53 [](size_t cur
, const FilterSubList
&sublist
) noexcept
-> size_t
54 { return cur
+ static_cast<uint
>(al::popcount(~sublist
.FreeMask
)); });
56 WARN("%zu Filter%s not deleted\n", count
, (count
==1)?"":"s");
59 void ALCdevice::enumerateHrtfs()
61 mHrtfList
= EnumerateHrtf(configValue
<std::string
>({}, "hrtf-paths"));
62 if(auto defhrtfopt
= configValue
<std::string
>({}, "default-hrtf"))
64 auto iter
= std::find(mHrtfList
.begin(), mHrtfList
.end(), *defhrtfopt
);
65 if(iter
== mHrtfList
.end())
66 WARN("Failed to find default HRTF \"%s\"\n", defhrtfopt
->c_str());
67 else if(iter
!= mHrtfList
.begin())
68 std::rotate(mHrtfList
.begin(), iter
, iter
+1);
72 auto ALCdevice::getOutputMode1() const noexcept
-> OutputMode1
74 if(mContexts
.load(std::memory_order_relaxed
)->empty())
75 return OutputMode1::Any
;
79 case DevFmtMono
: return OutputMode1::Mono
;
82 return OutputMode1::Hrtf
;
84 return OutputMode1::Uhj2
;
85 return OutputMode1::StereoBasic
;
86 case DevFmtQuad
: return OutputMode1::Quad
;
87 case DevFmtX51
: return OutputMode1::X51
;
88 case DevFmtX61
: return OutputMode1::X61
;
89 case DevFmtX71
: return OutputMode1::X71
;
95 return OutputMode1::Any
;