11 #include "backends/base.h"
12 #include "core/bformatdec.h"
13 #include "core/bs2b.h"
14 #include "core/front_stablizer.h"
15 #include "core/hrtf.h"
16 #include "core/logging.h"
17 #include "core/mastering.h"
18 #include "core/uhjfilter.h"
28 ALCdevice::ALCdevice(DeviceType type
) : DeviceBase
{type
}
31 ALCdevice::~ALCdevice()
33 TRACE("Freeing device %p\n", voidp
{this});
37 size_t count
{std::accumulate(BufferList
.cbegin(), BufferList
.cend(), size_t{0u},
38 [](size_t cur
, const BufferSubList
&sublist
) noexcept
-> size_t
39 { return cur
+ static_cast<uint
>(al::popcount(~sublist
.FreeMask
)); })};
41 WARN("%zu Buffer%s not deleted\n", count
, (count
==1)?"":"s");
43 count
= std::accumulate(EffectList
.cbegin(), EffectList
.cend(), size_t{0u},
44 [](size_t cur
, const EffectSubList
&sublist
) noexcept
-> size_t
45 { return cur
+ static_cast<uint
>(al::popcount(~sublist
.FreeMask
)); });
47 WARN("%zu Effect%s not deleted\n", count
, (count
==1)?"":"s");
49 count
= std::accumulate(FilterList
.cbegin(), FilterList
.cend(), size_t{0u},
50 [](size_t cur
, const FilterSubList
&sublist
) noexcept
-> size_t
51 { return cur
+ static_cast<uint
>(al::popcount(~sublist
.FreeMask
)); });
53 WARN("%zu Filter%s not deleted\n", count
, (count
==1)?"":"s");
56 void ALCdevice::enumerateHrtfs()
58 mHrtfList
= EnumerateHrtf(configValue
<std::string
>(nullptr, "hrtf-paths"));
59 if(auto defhrtfopt
= configValue
<std::string
>(nullptr, "default-hrtf"))
61 auto iter
= std::find(mHrtfList
.begin(), mHrtfList
.end(), *defhrtfopt
);
62 if(iter
== mHrtfList
.end())
63 WARN("Failed to find default HRTF \"%s\"\n", defhrtfopt
->c_str());
64 else if(iter
!= mHrtfList
.begin())
65 std::rotate(mHrtfList
.begin(), iter
, iter
+1);
69 auto ALCdevice::getOutputMode1() const noexcept
-> OutputMode1
71 if(mContexts
.load(std::memory_order_relaxed
)->empty())
72 return OutputMode1::Any
;
76 case DevFmtMono
: return OutputMode1::Mono
;
79 return OutputMode1::Hrtf
;
81 return OutputMode1::Uhj2
;
82 return OutputMode1::StereoBasic
;
83 case DevFmtQuad
: return OutputMode1::Quad
;
84 case DevFmtX51
: return OutputMode1::X51
;
85 case DevFmtX61
: return OutputMode1::X61
;
86 case DevFmtX71
: return OutputMode1::X71
;
92 return OutputMode1::Any
;