summaryrefslogtreecommitdiff
path: root/Source/Core/AudioCommon
diff options
context:
space:
mode:
authorLioncash <mathew1800@gmail.com>2015-12-02 20:00:48 -0500
committerLioncash <mathew1800@gmail.com>2015-12-02 20:05:18 -0500
commite0eef7bef4b37622deea2a57629b389766013c88 (patch)
tree37113cbed009743e55eb24732b1188bf165d8421 /Source/Core/AudioCommon
parenta759883ae5045d213837039983ac521e8252ee9e (diff)
WaveFile: Get rid of an explicit delete
Diffstat (limited to 'Source/Core/AudioCommon')
-rw-r--r--Source/Core/AudioCommon/WaveFile.cpp15
-rw-r--r--Source/Core/AudioCommon/WaveFile.h9
2 files changed, 10 insertions, 14 deletions
diff --git a/Source/Core/AudioCommon/WaveFile.cpp b/Source/Core/AudioCommon/WaveFile.cpp
index 692700a434..16089db8e3 100644
--- a/Source/Core/AudioCommon/WaveFile.cpp
+++ b/Source/Core/AudioCommon/WaveFile.cpp
@@ -9,26 +9,19 @@
#include "Common/Logging/Log.h"
#include "Core/ConfigManager.h"
-enum { BUF_SIZE = 32*1024 };
+constexpr size_t WaveFileWriter::BUFFER_SIZE;
-WaveFileWriter::WaveFileWriter():
- skip_silence(false),
- audio_size(0),
- conv_buffer(nullptr)
+WaveFileWriter::WaveFileWriter()
{
}
WaveFileWriter::~WaveFileWriter()
{
- delete[] conv_buffer;
Stop();
}
bool WaveFileWriter::Start(const std::string& filename, unsigned int HLESampleRate)
{
- if (!conv_buffer)
- conv_buffer = new short[BUF_SIZE];
-
// Check if the file is already open
if (file)
{
@@ -121,7 +114,7 @@ void WaveFileWriter::AddStereoSamplesBE(const short *sample_data, u32 count)
if (!file)
PanicAlertT("WaveFileWriter - file not open.");
- if (count > BUF_SIZE * 2)
+ if (count > BUFFER_SIZE * 2)
PanicAlert("WaveFileWriter - buffer too small (count = %u).", count);
if (skip_silence)
@@ -145,6 +138,6 @@ void WaveFileWriter::AddStereoSamplesBE(const short *sample_data, u32 count)
conv_buffer[2 * i + 1] = Common::swap16((u16)sample_data[2 * i]);
}
- file.WriteBytes(conv_buffer, count * 4);
+ file.WriteBytes(conv_buffer.data(), count * 4);
audio_size += count * 4;
}
diff --git a/Source/Core/AudioCommon/WaveFile.h b/Source/Core/AudioCommon/WaveFile.h
index 90ab26c9ea..7028acae3b 100644
--- a/Source/Core/AudioCommon/WaveFile.h
+++ b/Source/Core/AudioCommon/WaveFile.h
@@ -14,6 +14,7 @@
#pragma once
+#include <array>
#include <string>
#include "Common/CommonTypes.h"
#include "Common/FileUtil.h"
@@ -35,10 +36,12 @@ public:
u32 GetAudioSize() const { return audio_size; }
private:
+ static constexpr size_t BUFFER_SIZE = 32 * 1024;
+
File::IOFile file;
- bool skip_silence;
- u32 audio_size;
- short* conv_buffer;
+ bool skip_silence = false;
+ u32 audio_size = 0;
+ std::array<short, BUFFER_SIZE> conv_buffer{};
void Write(u32 value);
void Write4(const char* ptr);
};