aboutsummaryrefslogtreecommitdiffstats
path: root/alc
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2021-04-27 17:01:27 -0700
committerChris Robinson <[email protected]>2021-04-27 17:01:27 -0700
commit3d8e7051075927543eb6f330d6c1ca07d3690a7a (patch)
treeaed8cd61d16868af42730c0df7e0765c5268e571 /alc
parent06dcfc3fcfe7a93e9ec53406077b3211579cc92f (diff)
Move some functions to a more appropriate place
Diffstat (limited to 'alc')
-rw-r--r--alc/alc.cpp49
-rw-r--r--alc/device.cpp72
2 files changed, 72 insertions, 49 deletions
diff --git a/alc/alc.cpp b/alc/alc.cpp
index 9eface89..856deb79 100644
--- a/alc/alc.cpp
+++ b/alc/alc.cpp
@@ -2300,55 +2300,6 @@ static bool ResetDeviceParams(ALCdevice *device, const int *attrList)
}
-DeviceBase::DeviceBase(DeviceType type) : Type{type}, mContexts{&sEmptyContextArray}
-{
-}
-
-DeviceBase::~DeviceBase()
-{
- auto *oldarray = mContexts.exchange(nullptr, std::memory_order_relaxed);
- if(oldarray != &sEmptyContextArray) delete oldarray;
-}
-
-ALCdevice::~ALCdevice()
-{
- TRACE("Freeing device %p\n", voidp{this});
-
- Backend = nullptr;
-
- size_t count{std::accumulate(BufferList.cbegin(), BufferList.cend(), size_t{0u},
- [](size_t cur, const BufferSubList &sublist) noexcept -> size_t
- { return cur + static_cast<uint>(al::popcount(~sublist.FreeMask)); })};
- if(count > 0)
- WARN("%zu Buffer%s not deleted\n", count, (count==1)?"":"s");
-
- count = std::accumulate(EffectList.cbegin(), EffectList.cend(), size_t{0u},
- [](size_t cur, const EffectSubList &sublist) noexcept -> size_t
- { return cur + static_cast<uint>(al::popcount(~sublist.FreeMask)); });
- if(count > 0)
- WARN("%zu Effect%s not deleted\n", count, (count==1)?"":"s");
-
- count = std::accumulate(FilterList.cbegin(), FilterList.cend(), size_t{0u},
- [](size_t cur, const FilterSubList &sublist) noexcept -> size_t
- { return cur + static_cast<uint>(al::popcount(~sublist.FreeMask)); });
- if(count > 0)
- WARN("%zu Filter%s not deleted\n", count, (count==1)?"":"s");
-}
-
-void ALCdevice::enumerateHrtfs()
-{
- mHrtfList = EnumerateHrtf(ConfigValueStr(DeviceName.c_str(), nullptr, "hrtf-paths"));
- if(auto defhrtfopt = ConfigValueStr(DeviceName.c_str(), nullptr, "default-hrtf"))
- {
- auto iter = std::find(mHrtfList.begin(), mHrtfList.end(), *defhrtfopt);
- if(iter == mHrtfList.end())
- WARN("Failed to find default HRTF \"%s\"\n", defhrtfopt->c_str());
- else if(iter != mHrtfList.begin())
- std::rotate(mHrtfList.begin(), iter, iter+1);
- }
-}
-
-
/** Checks if the device handle is valid, and returns a new reference if so. */
static DeviceRef VerifyDevice(ALCdevice *device)
{
diff --git a/alc/device.cpp b/alc/device.cpp
index 954a790b..0f7d2b57 100644
--- a/alc/device.cpp
+++ b/alc/device.cpp
@@ -2,3 +2,75 @@
#include "config.h"
#include "device.h"
+
+#include <numeric>
+#include <stddef.h>
+
+#include "albit.h"
+#include "alconfig.h"
+#include "backends/base.h"
+#include "core/bformatdec.h"
+#include "core/bs2b.h"
+#include "core/front_stablizer.h"
+#include "core/hrtf.h"
+#include "core/logging.h"
+#include "core/mastering.h"
+#include "core/uhjfilter.h"
+
+
+namespace {
+
+using voidp = void*;
+
+} // namespace
+
+
+/* This should be in core/device.cpp. */
+DeviceBase::DeviceBase(DeviceType type) : Type{type}, mContexts{&sEmptyContextArray}
+{
+}
+
+DeviceBase::~DeviceBase()
+{
+ auto *oldarray = mContexts.exchange(nullptr, std::memory_order_relaxed);
+ if(oldarray != &sEmptyContextArray) delete oldarray;
+}
+
+
+ALCdevice::~ALCdevice()
+{
+ TRACE("Freeing device %p\n", voidp{this});
+
+ Backend = nullptr;
+
+ size_t count{std::accumulate(BufferList.cbegin(), BufferList.cend(), size_t{0u},
+ [](size_t cur, const BufferSubList &sublist) noexcept -> size_t
+ { return cur + static_cast<uint>(al::popcount(~sublist.FreeMask)); })};
+ if(count > 0)
+ WARN("%zu Buffer%s not deleted\n", count, (count==1)?"":"s");
+
+ count = std::accumulate(EffectList.cbegin(), EffectList.cend(), size_t{0u},
+ [](size_t cur, const EffectSubList &sublist) noexcept -> size_t
+ { return cur + static_cast<uint>(al::popcount(~sublist.FreeMask)); });
+ if(count > 0)
+ WARN("%zu Effect%s not deleted\n", count, (count==1)?"":"s");
+
+ count = std::accumulate(FilterList.cbegin(), FilterList.cend(), size_t{0u},
+ [](size_t cur, const FilterSubList &sublist) noexcept -> size_t
+ { return cur + static_cast<uint>(al::popcount(~sublist.FreeMask)); });
+ if(count > 0)
+ WARN("%zu Filter%s not deleted\n", count, (count==1)?"":"s");
+}
+
+void ALCdevice::enumerateHrtfs()
+{
+ mHrtfList = EnumerateHrtf(ConfigValueStr(DeviceName.c_str(), nullptr, "hrtf-paths"));
+ if(auto defhrtfopt = ConfigValueStr(DeviceName.c_str(), nullptr, "default-hrtf"))
+ {
+ auto iter = std::find(mHrtfList.begin(), mHrtfList.end(), *defhrtfopt);
+ if(iter == mHrtfList.end())
+ WARN("Failed to find default HRTF \"%s\"\n", defhrtfopt->c_str());
+ else if(iter != mHrtfList.begin())
+ std::rotate(mHrtfList.begin(), iter, iter+1);
+ }
+}