From 6caa98d416ab17648c9653f04972d30d18b04596 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Fri, 20 Oct 2017 07:35:22 -0700 Subject: [PATCH] Add a constexpr AttributesEnd to cap AttributePair arrays --- examples/alure-hrtf.cpp | 4 ++-- include/AL/alure2.h | 1 + src/device.cpp | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/examples/alure-hrtf.cpp b/examples/alure-hrtf.cpp index 4b8aea2..e650ccc 100644 --- a/examples/alure-hrtf.cpp +++ b/examples/alure-hrtf.cpp @@ -58,7 +58,7 @@ int main(int argc, char *argv[]) else attrs.push_back({ALC_HRTF_ID_SOFT, std::distance(hrtf_names.begin(), iter)}); } - attrs.push_back({0,0}); + attrs.push_back(alure::AttributesEnd); alure::Context ctx = dev.createContext(attrs); alure::Context::MakeCurrent(ctx); @@ -77,7 +77,7 @@ int main(int argc, char *argv[]) alure::Array attrs{{ {ALC_HRTF_SOFT, ALC_TRUE}, {ALC_HRTF_ID_SOFT, std::distance(hrtf_names.begin(), iter)}, - {0, 0} + alure::AttributesEnd }}; dev.reset(attrs); std::cout<< "Using HRTF \""<& operator<<(std::basic_ostream &lhs, BasicStr */ using AttributePair = std::pair; static_assert(sizeof(AttributePair) == sizeof(ALCint[2]), "Bad AttributePair size"); +constexpr AttributePair AttributesEnd{0, 0}; struct FilterParams { diff --git a/src/device.cpp b/src/device.cpp index 97b6f98..6295981 100644 --- a/src/device.cpp +++ b/src/device.cpp @@ -201,7 +201,7 @@ void DeviceImpl::reset(ArrayView attributes) Vector attrs; attrs.reserve(attributes.size() + 1); std::copy(attributes.begin(), attributes.end(), std::back_inserter(attrs)); - attrs.push_back({0, 0}); + attrs.push_back(AttributesEnd); return alcResetDeviceSOFT(mDevice, &std::get<0>(attrs.front())); } return alcResetDeviceSOFT(mDevice, &std::get<0>(attributes.front())); @@ -232,7 +232,7 @@ Context DeviceImpl::createContext(ArrayView attributes) Vector attrs; attrs.reserve(attributes.size() + 1); std::copy(attributes.begin(), attributes.end(), std::back_inserter(attrs)); - attrs.push_back({0, 0}); + attrs.push_back(AttributesEnd); return alcCreateContext(mDevice, &std::get<0>(attrs.front())); } return alcCreateContext(mDevice, &std::get<0>(attributes.front())); -- 2.11.4.GIT