From f4fafbcb268c440433bca587689870dbe64677db Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sat, 24 Aug 2019 23:05:19 -0400 Subject: [PATCH] LtRtProcessing: Simplify allocations in LtRtProcessing constructor We can use std::make_unique, which provides the same behavior as zeroing out the buffer. Now we can remove the use of memset here. --- lib/audiodev/LtRtProcessing.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/lib/audiodev/LtRtProcessing.cpp b/lib/audiodev/LtRtProcessing.cpp index 1d93784..2bf0209 100644 --- a/lib/audiodev/LtRtProcessing.cpp +++ b/lib/audiodev/LtRtProcessing.cpp @@ -239,19 +239,16 @@ LtRtProcessing::LtRtProcessing(int _5msFrames, const AudioVoiceEngineMixInfo& mi m_inMixInfo.m_channelMap.m_channels[3] = AudioChannel::RearLeft; m_inMixInfo.m_channelMap.m_channels[4] = AudioChannel::RearRight; - int samples = m_windowFrames * (5 * 2 + 2 * 2); + const int samples = m_windowFrames * (5 * 2 + 2 * 2); switch (mixInfo.m_sampleFormat) { case SOXR_INT16_I: - m_16Buffer.reset(new int16_t[samples]); - memset(m_16Buffer.get(), 0, sizeof(int16_t) * samples); + m_16Buffer = std::make_unique(samples); break; case SOXR_INT32_I: - m_32Buffer.reset(new int32_t[samples]); - memset(m_32Buffer.get(), 0, sizeof(int32_t) * samples); + m_32Buffer = std::make_unique(samples); break; case SOXR_FLOAT32_I: - m_fltBuffer.reset(new float[samples]); - memset(m_fltBuffer.get(), 0, sizeof(float) * samples); + m_fltBuffer = std::make_unique(samples); break; default: break;