|
3 | 3 |
|
4 | 4 | #include "Core/HW/WiimoteEmu/Speaker.h"
|
5 | 5 |
|
6 |
| -#include <memory> |
| 6 | +#include <cassert> |
7 | 7 |
|
8 | 8 | #include "AudioCommon/AudioCommon.h"
|
| 9 | + |
9 | 10 | #include "Common/CommonTypes.h"
|
10 | 11 | #include "Common/Logging/Log.h"
|
| 12 | + |
11 | 13 | #include "Core/ConfigManager.h"
|
12 | 14 | #include "Core/HW/WiimoteEmu/WiimoteEmu.h"
|
13 | 15 | #include "Core/System.h"
|
| 16 | + |
14 | 17 | #include "InputCommon/ControllerEmu/ControlGroup/ControlGroup.h"
|
15 | 18 | #include "InputCommon/ControllerEmu/Setting/NumericSetting.h"
|
16 | 19 |
|
@@ -62,8 +65,9 @@ void SpeakerLogic::SpeakerData(const u8* data, int length, float speaker_pan)
|
62 | 65 |
|
63 | 66 | // Even if volume is zero we process samples to maintain proper decoder state.
|
64 | 67 |
|
65 |
| - // TODO consider using static max size instead of new |
66 |
| - std::unique_ptr<s16[]> samples(new s16[length * 2]); |
| 68 | + // Potentially 40 resulting samples. |
| 69 | + std::array<s16, WiimoteCommon::OutputReportSpeakerData::DATA_SIZE * 2> samples; |
| 70 | + assert(length * 2 <= samples.size()); |
67 | 71 |
|
68 | 72 | unsigned int sample_rate_dividend, sample_length;
|
69 | 73 | u8 volume_divisor;
|
@@ -130,7 +134,7 @@ void SpeakerLogic::SpeakerData(const u8* data, int length, float speaker_pan)
|
130 | 134 | // ADPCM sample rate is thought to be x2.(3000 x2 = 6000).
|
131 | 135 | const unsigned int sample_rate = sample_rate_dividend / reg_data.sample_rate;
|
132 | 136 | sound_stream->GetMixer()->PushWiimoteSpeakerSamples(
|
133 |
| - samples.get(), sample_length, Mixer::FIXED_SAMPLE_RATE_DIVIDEND / (sample_rate * 2)); |
| 137 | + samples.data(), sample_length, Mixer::FIXED_SAMPLE_RATE_DIVIDEND / (sample_rate * 2)); |
134 | 138 | }
|
135 | 139 |
|
136 | 140 | void SpeakerLogic::Reset()
|
|
0 commit comments