Avoid some pre-C++14 workarounds

This commit is contained in:
Chris Robinson
2020-03-22 08:51:06 -07:00
parent 040309b9f4
commit 9ce182228d
7 changed files with 20 additions and 31 deletions
+1 -1
View File
@@ -2085,7 +2085,7 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList)
case DevFmtX71:
if(GetConfigValueBool(device->DeviceName.c_str(), nullptr, "front-stablizer", 0))
{
auto stablizer = al::make_unique<FrontStablizer>();
auto stablizer = std::make_unique<FrontStablizer>();
/* Initialize band-splitting filters for the front-left and front-
* right channels, with a crossover at 5khz (could be higher).
*/
+9 -10
View File
@@ -101,8 +101,7 @@ inline constexpr ReferenceTime operator "" _reftime(unsigned long long int n) no
#define X7DOT1 (SPEAKER_FRONT_LEFT|SPEAKER_FRONT_RIGHT|SPEAKER_FRONT_CENTER|SPEAKER_LOW_FREQUENCY|SPEAKER_BACK_LEFT|SPEAKER_BACK_RIGHT|SPEAKER_SIDE_LEFT|SPEAKER_SIDE_RIGHT)
#define X7DOT1_WIDE (SPEAKER_FRONT_LEFT|SPEAKER_FRONT_RIGHT|SPEAKER_FRONT_CENTER|SPEAKER_LOW_FREQUENCY|SPEAKER_BACK_LEFT|SPEAKER_BACK_RIGHT|SPEAKER_FRONT_LEFT_OF_CENTER|SPEAKER_FRONT_RIGHT_OF_CENTER)
/* TODO: This can't be constexpr in C++11. */
inline uint32_t MaskFromTopBits(uint32_t b) noexcept
constexpr inline uint32_t MaskFromTopBits(uint32_t b) noexcept
{
b |= b>>1;
b |= b>>2;
@@ -111,14 +110,14 @@ inline uint32_t MaskFromTopBits(uint32_t b) noexcept
b |= b>>16;
return b;
}
const uint32_t MonoMask{MaskFromTopBits(MONO)};
const uint32_t StereoMask{MaskFromTopBits(STEREO)};
const uint32_t QuadMask{MaskFromTopBits(QUAD)};
const uint32_t X51Mask{MaskFromTopBits(X5DOT1)};
const uint32_t X51RearMask{MaskFromTopBits(X5DOT1REAR)};
const uint32_t X61Mask{MaskFromTopBits(X6DOT1)};
const uint32_t X71Mask{MaskFromTopBits(X7DOT1)};
const uint32_t X71WideMask{MaskFromTopBits(X7DOT1_WIDE)};
constexpr uint32_t MonoMask{MaskFromTopBits(MONO)};
constexpr uint32_t StereoMask{MaskFromTopBits(STEREO)};
constexpr uint32_t QuadMask{MaskFromTopBits(QUAD)};
constexpr uint32_t X51Mask{MaskFromTopBits(X5DOT1)};
constexpr uint32_t X51RearMask{MaskFromTopBits(X5DOT1REAR)};
constexpr uint32_t X61Mask{MaskFromTopBits(X6DOT1)};
constexpr uint32_t X71Mask{MaskFromTopBits(X7DOT1)};
constexpr uint32_t X71WideMask{MaskFromTopBits(X7DOT1_WIDE)};
#define DEVNAME_HEAD "OpenAL Soft on "
+3 -4
View File
@@ -44,10 +44,9 @@ using complex_d = std::complex<double>;
#define FIFO_LATENCY (HIL_STEP * (OVERSAMP-1))
/* Define a Hann window, used to filter the HIL input and output. */
/* Making this constexpr seems to require C++14. */
std::array<ALdouble,HIL_SIZE> InitHannWindow()
std::array<double,HIL_SIZE> InitHannWindow()
{
std::array<ALdouble,HIL_SIZE> ret;
std::array<double,HIL_SIZE> ret;
/* Create lookup table of the Hann window for the desired size, i.e. HIL_SIZE */
for(size_t i{0};i < HIL_SIZE>>1;i++)
{
@@ -57,7 +56,7 @@ std::array<ALdouble,HIL_SIZE> InitHannWindow()
}
return ret;
}
alignas(16) const std::array<ALdouble,HIL_SIZE> HannWindow = InitHannWindow();
alignas(16) const std::array<double,HIL_SIZE> HannWindow = InitHannWindow();
struct FshifterState final : public EffectState {
+3 -4
View File
@@ -50,10 +50,9 @@ using complex_d = std::complex<double>;
#define FIFO_LATENCY (STFT_STEP * (OVERSAMP-1))
/* Define a Hann window, used to filter the STFT input and output. */
/* Making this constexpr seems to require C++14. */
std::array<ALdouble,STFT_SIZE> InitHannWindow()
std::array<double,STFT_SIZE> InitHannWindow()
{
std::array<ALdouble,STFT_SIZE> ret;
std::array<double,STFT_SIZE> ret;
/* Create lookup table of the Hann window for the desired size, i.e. HIL_SIZE */
for(size_t i{0};i < STFT_SIZE>>1;i++)
{
@@ -63,7 +62,7 @@ std::array<ALdouble,STFT_SIZE> InitHannWindow()
}
return ret;
}
alignas(16) const std::array<ALdouble,STFT_SIZE> HannWindow = InitHannWindow();
alignas(16) const std::array<double,STFT_SIZE> HannWindow = InitHannWindow();
struct ALphasor {
+2 -2
View File
@@ -1392,12 +1392,12 @@ HrtfStorePtr GetLoadedHrtf(const std::string &name, const char *devname, const A
ERR("Could not get resource %u, %s\n", residx, name.c_str());
return nullptr;
}
stream = al::make_unique<idstream>(res.begin(), res.end());
stream = std::make_unique<idstream>(res.begin(), res.end());
}
else
{
TRACE("Loading %s...\n", fname.c_str());
auto fstr = al::make_unique<al::ifstream>(fname.c_str(), std::ios::binary);
auto fstr = std::make_unique<al::ifstream>(fname.c_str(), std::ios::binary);
if(!fstr->is_open())
{
ERR("Could not open %s\n", fname.c_str());
+2 -2
View File
@@ -831,7 +831,7 @@ no_hrtf:
{
if(*cflevopt > 0 && *cflevopt <= 6)
{
device->Bs2b = al::make_unique<bs2b>();
device->Bs2b = std::make_unique<bs2b>();
bs2b_set_params(device->Bs2b.get(), *cflevopt,
static_cast<int>(device->Frequency));
TRACE("BS2B enabled\n");
@@ -852,7 +852,7 @@ no_hrtf:
}
if(device->mRenderMode == NormalRender)
{
device->Uhj_Encoder = al::make_unique<Uhj2Encoder>();
device->Uhj_Encoder = std::make_unique<Uhj2Encoder>();
TRACE("UHJ enabled\n");
InitUhjPanning(device);
device->PostProcess = &ALCdevice::ProcessUhj;
-8
View File
@@ -216,14 +216,6 @@ inline T1 uninitialized_move_n(T0 first, N count, const T1 output)
}
/* std::make_unique was added with C++14, so until we rely on that, make our
* own version.
*/
template<typename T, typename ...ArgsT>
std::unique_ptr<T> make_unique(ArgsT&&...args)
{ return std::unique_ptr<T>{new T{std::forward<ArgsT>(args)...}}; }
/* A flexible array type. Used either standalone or at the end of a parent
* struct, with placement new, to have a run-time-sized array that's embedded
* with its size.