diff options
| author | Lioncash <mathew1800@gmail.com> | 2016-01-17 22:33:21 -0500 |
|---|---|---|
| committer | Lioncash <mathew1800@gmail.com> | 2016-01-17 22:33:21 -0500 |
| commit | 2ff59233346711f789bfe17eeed81e5c87f23176 (patch) | |
| tree | b9dac75f6897d633dfc3f841b37d1654317b2b4f /Source | |
| parent | 24c228c6e9c73acceb6a7d74d51211865b80b67e (diff) | |
DSPEmulator: Make CreateDSPEmulator return a unique_ptr
Diffstat (limited to 'Source')
| -rw-r--r-- | Source/Core/Core/DSPEmulator.cpp | 13 | ||||
| -rw-r--r-- | Source/Core/Core/DSPEmulator.h | 3 | ||||
| -rw-r--r-- | Source/Core/Core/HW/DSP.cpp | 13 |
3 files changed, 15 insertions, 14 deletions
diff --git a/Source/Core/Core/DSPEmulator.cpp b/Source/Core/Core/DSPEmulator.cpp index 5aaf8a602c..9a5cd62a95 100644 --- a/Source/Core/Core/DSPEmulator.cpp +++ b/Source/Core/Core/DSPEmulator.cpp @@ -2,15 +2,16 @@ // Licensed under GPLv2+ // Refer to the license.txt file included. -#include "Core/DSPEmulator.h" +#include <memory> +#include "Core/DSPEmulator.h" #include "Core/HW/DSPHLE/DSPHLE.h" #include "Core/HW/DSPLLE/DSPLLE.h" -DSPEmulator *CreateDSPEmulator(bool HLE) +std::unique_ptr<DSPEmulator> CreateDSPEmulator(bool hle) { - if (HLE) - return new DSPHLE(); - else - return new DSPLLE(); + if (hle) + return std::make_unique<DSPHLE>(); + + return std::make_unique<DSPLLE>(); } diff --git a/Source/Core/Core/DSPEmulator.h b/Source/Core/Core/DSPEmulator.h index b05e56ee1f..e07f6dd6e3 100644 --- a/Source/Core/Core/DSPEmulator.h +++ b/Source/Core/Core/DSPEmulator.h @@ -4,6 +4,7 @@ #pragma once +#include <memory> #include "Common/CommonTypes.h" class PointerWrap; @@ -32,4 +33,4 @@ public: virtual u32 DSP_UpdateRate() = 0; }; -DSPEmulator *CreateDSPEmulator(bool HLE); +std::unique_ptr<DSPEmulator> CreateDSPEmulator(bool hle); diff --git a/Source/Core/Core/HW/DSP.cpp b/Source/Core/Core/HW/DSP.cpp index 0956952fa6..a7b3641e81 100644 --- a/Source/Core/Core/HW/DSP.cpp +++ b/Source/Core/Core/HW/DSP.cpp @@ -23,11 +23,11 @@ // the just used buffer through the AXList (or whatever it might be called in // Nintendo games). -#include "AudioCommon/AudioCommon.h" +#include <memory> +#include "AudioCommon/AudioCommon.h" #include "Common/CommonTypes.h" #include "Common/MemoryUtil.h" - #include "Core/ConfigManager.h" #include "Core/CoreTiming.h" #include "Core/DSPEmulator.h" @@ -167,7 +167,7 @@ static ARAM_Info g_ARAM_Info; static u16 g_AR_MODE; static u16 g_AR_REFRESH; -static DSPEmulator *dsp_emulator; +static std::unique_ptr<DSPEmulator> dsp_emulator; static int dsp_slice = 0; static bool dsp_is_lle = false; @@ -230,9 +230,9 @@ void FlushInstantDMA(u32 address) } } -DSPEmulator *GetDSPEmulator() +DSPEmulator* GetDSPEmulator() { - return dsp_emulator; + return dsp_emulator.get(); } void Init(bool hle) @@ -284,8 +284,7 @@ void Shutdown() } dsp_emulator->Shutdown(); - delete dsp_emulator; - dsp_emulator = nullptr; + dsp_emulator.reset(); } void RegisterMMIO(MMIO::Mapping* mmio, u32 base) |
