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.
This commit is contained in:
Lioncash 2019-08-24 23:05:19 -04:00
parent f8e827fcd4
commit f4fafbcb26
1 changed files with 4 additions and 7 deletions

View File

@ -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[3] = AudioChannel::RearLeft;
m_inMixInfo.m_channelMap.m_channels[4] = AudioChannel::RearRight; 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) { switch (mixInfo.m_sampleFormat) {
case SOXR_INT16_I: case SOXR_INT16_I:
m_16Buffer.reset(new int16_t[samples]); m_16Buffer = std::make_unique<int16_t[]>(samples);
memset(m_16Buffer.get(), 0, sizeof(int16_t) * samples);
break; break;
case SOXR_INT32_I: case SOXR_INT32_I:
m_32Buffer.reset(new int32_t[samples]); m_32Buffer = std::make_unique<int32_t[]>(samples);
memset(m_32Buffer.get(), 0, sizeof(int32_t) * samples);
break; break;
case SOXR_FLOAT32_I: case SOXR_FLOAT32_I:
m_fltBuffer.reset(new float[samples]); m_fltBuffer = std::make_unique<float[]>(samples);
memset(m_fltBuffer.get(), 0, sizeof(float) * samples);
break; break;
default: default:
break; break;