diff options
-rw-r--r-- | Alc/alc.cpp | 8 | ||||
-rw-r--r-- | Alc/hrtf.cpp | 4 | ||||
-rw-r--r-- | Alc/mastering.cpp | 9 | ||||
-rw-r--r-- | Alc/panning.cpp | 6 | ||||
-rw-r--r-- | OpenAL32/alAuxEffectSlot.cpp | 2 | ||||
-rw-r--r-- | common/almalloc.h | 7 |
6 files changed, 21 insertions, 15 deletions
diff --git a/Alc/alc.cpp b/Alc/alc.cpp index 0b89bd71..59582ea6 100644 --- a/Alc/alc.cpp +++ b/Alc/alc.cpp @@ -3453,7 +3453,7 @@ ALC_API ALCcontext* ALC_APIENTRY alcCreateContext(ALCdevice *device, const ALCin if(DefaultEffect.type != AL_EFFECT_NULL && dev->Type == Playback) { - ALContext->DefaultSlot.reset(new ALeffectslot{}); + ALContext->DefaultSlot = al::make_unique<ALeffectslot>(); if(InitEffectSlot(ALContext->DefaultSlot.get()) == AL_NO_ERROR) aluInitEffectPanning(ALContext->DefaultSlot.get()); else @@ -3652,7 +3652,7 @@ ALC_API ALCdevice* ALC_APIENTRY alcOpenDevice(const ALCchar *deviceName) )) deviceName = nullptr; - std::unique_ptr<ALCdevice> device{new ALCdevice{Playback}}; + auto device = al::make_unique<ALCdevice>(Playback); //Set output format device->FmtChans = DevFmtChannelsDefault; @@ -3896,7 +3896,7 @@ ALC_API ALCdevice* ALC_APIENTRY alcCaptureOpenDevice(const ALCchar *deviceName, if(deviceName && (!deviceName[0] || strcasecmp(deviceName, alcDefaultName) == 0 || strcasecmp(deviceName, "openal-soft") == 0)) deviceName = nullptr; - std::unique_ptr<ALCdevice> device{new ALCdevice{Capture}}; + auto device = al::make_unique<ALCdevice>(Capture); device->Frequency = frequency; device->Flags |= DEVICE_FREQUENCY_REQUEST; @@ -4060,7 +4060,7 @@ ALC_API ALCdevice* ALC_APIENTRY alcLoopbackOpenDeviceSOFT(const ALCchar *deviceN return nullptr; } - std::unique_ptr<ALCdevice> device{new ALCdevice{Loopback}}; + auto device = al::make_unique<ALCdevice>(Loopback); device->SourcesMax = 256; device->AuxiliaryEffectSlotMax = 64; diff --git a/Alc/hrtf.cpp b/Alc/hrtf.cpp index 1995119a..2cdabc2a 100644 --- a/Alc/hrtf.cpp +++ b/Alc/hrtf.cpp @@ -1198,14 +1198,14 @@ HrtfEntry *GetLoadedHrtf(HrtfHandle *handle) ERR("Could not get resource %u, %s\n", residx, name); return nullptr; } - stream.reset(new idstream{res.data, res.data+res.size}); + stream = al::make_unique<idstream>(res.data, res.data+res.size); } else { name = handle->filename; TRACE("Loading %s...\n", handle->filename); - std::unique_ptr<al::ifstream> fstr{new al::ifstream{handle->filename, std::ios::binary}}; + auto fstr = al::make_unique<al::ifstream>(handle->filename, std::ios::binary); if(!fstr->is_open()) { ERR("Could not open %s\n", handle->filename); diff --git a/Alc/mastering.cpp b/Alc/mastering.cpp index e886b127..dcc5cf40 100644 --- a/Alc/mastering.cpp +++ b/Alc/mastering.cpp @@ -358,20 +358,19 @@ std::unique_ptr<Compressor> CompressorInit(const ALsizei NumChans, const ALuint clampf(std::round(LookAheadTime*SampleRate), 0.0f, BUFFERSIZE-1)); auto hold = static_cast<ALsizei>(clampf(std::round(HoldTime*SampleRate), 0.0f, BUFFERSIZE-1)); - std::unique_ptr<Compressor> Comp; size_t size{sizeof(Compressor)}; if(lookAhead > 0) { - size += sizeof(*Comp->mDelay) * NumChans; + size += sizeof(*Compressor::mDelay) * NumChans; /* The sliding hold implementation doesn't handle a length of 1. A 1- * sample hold is useless anyway, it would only ever give back what was * just given to it. */ if(hold > 1) - size += sizeof(*Comp->mHold); + size += sizeof(*Compressor::mHold); } - Comp = std::unique_ptr<Compressor>{new (al_calloc(16, size)) Compressor{}}; + auto Comp = std::unique_ptr<Compressor>{new (al_calloc(16, size)) Compressor{}}; Comp->mNumChans = NumChans; Comp->mSampleRate = SampleRate; Comp->mAuto.Knee = AutoKnee != AL_FALSE; @@ -388,7 +387,7 @@ std::unique_ptr<Compressor> CompressorInit(const ALsizei NumChans, const ALuint Comp->mAttack = maxf(1.0f, AttackTime * SampleRate); Comp->mRelease = maxf(1.0f, ReleaseTime * SampleRate); - /* Knee width automation actually treats the compressor as a limiter. By + /* Knee width automation actually treats the compressor as a limiter. By * varying the knee width, it can effectively be seen as applying * compression over a wide range of ratios. */ diff --git a/Alc/panning.cpp b/Alc/panning.cpp index 5e7806ec..1582cbae 100644 --- a/Alc/panning.cpp +++ b/Alc/panning.cpp @@ -956,12 +956,12 @@ void aluInitRenderer(ALCdevice *device, ALint hrtf_id, HrtfRequestMode hrtf_appr case DevFmtX71: if(GetConfigValueBool(devname, nullptr, "front-stablizer", 0)) { + auto stablizer = al::make_unique<FrontStablizer>(); /* Initialize band-splitting filters for the front-left and * front-right channels, with a crossover at 5khz (could be * higher). */ - ALfloat scale = (ALfloat)(5000.0 / device->Frequency); - std::unique_ptr<FrontStablizer> stablizer{new FrontStablizer{}}; + const ALfloat scale{(ALfloat)(5000.0 / device->Frequency)}; stablizer->LFilter.init(scale); stablizer->RFilter = stablizer->LFilter; @@ -969,7 +969,7 @@ void aluInitRenderer(ALCdevice *device, ALint hrtf_id, HrtfRequestMode hrtf_appr /* Initialize all-pass filters for all other channels. */ stablizer->APFilter[0].init(scale); std::fill(std::begin(stablizer->APFilter)+1, std::end(stablizer->APFilter), - stablizer->APFilter[0]); + stablizer->APFilter[0]); device->Stablizer = std::move(stablizer); } diff --git a/OpenAL32/alAuxEffectSlot.cpp b/OpenAL32/alAuxEffectSlot.cpp index fc43edbe..0c2d7bec 100644 --- a/OpenAL32/alAuxEffectSlot.cpp +++ b/OpenAL32/alAuxEffectSlot.cpp @@ -213,7 +213,7 @@ AL_API ALvoid AL_APIENTRY alGenAuxiliaryEffectSlots(ALsizei n, ALuint *effectslo iter = context->EffectSlotList.end() - 1; } - *iter = std::unique_ptr<ALeffectslot>(new ALeffectslot{}); + *iter = al::make_unique<ALeffectslot>(); ALenum err{InitEffectSlot(iter->get())}; if(err != AL_NO_ERROR) { diff --git a/common/almalloc.h b/common/almalloc.h index 26fa37ee..15d0263a 100644 --- a/common/almalloc.h +++ b/common/almalloc.h @@ -83,6 +83,13 @@ inline T* assume_aligned(T *ptr) noexcept #endif } +/* 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)...}}; } + } // namespace al #endif /* AL_MALLOC_H */ |