Move some temp variables closer to where they're used
[openal-soft.git] / alc / device.cpp
blob01153d518c76d99b2564c9ee60331ef33f3b30f6
2 #include "config.h"
4 #include "device.h"
6 #include <numeric>
7 #include <stddef.h>
9 #include "albit.h"
10 #include "alconfig.h"
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"
21 namespace {
23 using voidp = void*;
25 } // namespace
28 ALCdevice::ALCdevice(DeviceType type) : DeviceBase{type}
29 { }
31 ALCdevice::~ALCdevice()
33 TRACE("Freeing device %p\n", voidp{this});
35 Backend = nullptr;
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)); })};
40 if(count > 0)
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)); });
46 if(count > 0)
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)); });
52 if(count > 0)
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);