unique_ptr'ing things and removing some XECLEANUP.
This commit is contained in:
@@ -10,22 +10,16 @@
|
||||
#include <xenia/apu/apu.h>
|
||||
#include <xenia/apu/apu-private.h>
|
||||
|
||||
|
||||
|
||||
using namespace xe;
|
||||
using namespace xe::apu;
|
||||
|
||||
|
||||
DEFINE_string(apu, "any",
|
||||
"Audio system. Use: [any, nop, xaudio2]");
|
||||
|
||||
DEFINE_string(apu, "any", "Audio system. Use: [any, nop, xaudio2]");
|
||||
|
||||
#include <xenia/apu/nop/nop_apu.h>
|
||||
AudioSystem* xe::apu::CreateNop(Emulator* emulator) {
|
||||
std::unique_ptr<AudioSystem> xe::apu::CreateNop(Emulator* emulator) {
|
||||
return xe::apu::nop::Create(emulator);
|
||||
}
|
||||
|
||||
|
||||
#if XE_PLATFORM_WIN32
|
||||
#include <xenia/apu/xaudio2/xaudio2_apu.h>
|
||||
AudioSystem* xe::apu::CreateXAudio2(Emulator* emulator) {
|
||||
@@ -33,17 +27,16 @@ AudioSystem* xe::apu::CreateXAudio2(Emulator* emulator) {
|
||||
}
|
||||
#endif // WIN32
|
||||
|
||||
AudioSystem* xe::apu::Create(Emulator* emulator) {
|
||||
std::unique_ptr<AudioSystem> xe::apu::Create(Emulator* emulator) {
|
||||
if (FLAGS_apu.compare("nop") == 0) {
|
||||
return CreateNop(emulator);
|
||||
#if XE_PLATFORM_WIN32
|
||||
}
|
||||
else if (FLAGS_apu.compare("xaudio2") == 0) {
|
||||
} else if (FLAGS_apu.compare("xaudio2") == 0) {
|
||||
return CreateXAudio2(emulator);
|
||||
#endif // WIN32
|
||||
} else {
|
||||
// Create best available.
|
||||
AudioSystem* best = NULL;
|
||||
std::unique_ptr<AudioSystem> best;
|
||||
|
||||
#if XE_PLATFORM_WIN32
|
||||
best = CreateXAudio2(emulator);
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
#ifndef XENIA_APU_APU_H_
|
||||
#define XENIA_APU_APU_H_
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <xenia/apu/audio_system.h>
|
||||
|
||||
namespace xe {
|
||||
@@ -19,12 +21,12 @@ class Emulator;
|
||||
namespace xe {
|
||||
namespace apu {
|
||||
|
||||
AudioSystem* Create(Emulator* emulator);
|
||||
std::unique_ptr<AudioSystem> Create(Emulator* emulator);
|
||||
|
||||
AudioSystem* CreateNop(Emulator* emulator);
|
||||
std::unique_ptr<AudioSystem> CreateNop(Emulator* emulator);
|
||||
|
||||
#if XE_PLATFORM_WIN32
|
||||
AudioSystem* CreateXAudio2(Emulator* emulator);
|
||||
std::unique_ptr<AudioSystem> CreateXAudio2(Emulator* emulator);
|
||||
#endif // WIN32
|
||||
|
||||
} // namespace apu
|
||||
|
||||
@@ -11,34 +11,30 @@
|
||||
|
||||
#include <xenia/apu/nop/nop_audio_system.h>
|
||||
|
||||
|
||||
using namespace xe;
|
||||
using namespace xe::apu;
|
||||
using namespace xe::apu::nop;
|
||||
|
||||
|
||||
namespace {
|
||||
void InitializeIfNeeded();
|
||||
void CleanupOnShutdown();
|
||||
void InitializeIfNeeded();
|
||||
void CleanupOnShutdown();
|
||||
|
||||
void InitializeIfNeeded() {
|
||||
static bool has_initialized = false;
|
||||
if (has_initialized) {
|
||||
return;
|
||||
}
|
||||
has_initialized = true;
|
||||
|
||||
//
|
||||
|
||||
atexit(CleanupOnShutdown);
|
||||
void InitializeIfNeeded() {
|
||||
static bool has_initialized = false;
|
||||
if (has_initialized) {
|
||||
return;
|
||||
}
|
||||
has_initialized = true;
|
||||
|
||||
void CleanupOnShutdown() {
|
||||
}
|
||||
//
|
||||
|
||||
atexit(CleanupOnShutdown);
|
||||
}
|
||||
|
||||
void CleanupOnShutdown() {}
|
||||
}
|
||||
|
||||
AudioSystem* xe::apu::nop::Create(Emulator* emulator) {
|
||||
std::unique_ptr<AudioSystem> xe::apu::nop::Create(Emulator* emulator) {
|
||||
InitializeIfNeeded();
|
||||
return new NopAudioSystem(emulator);
|
||||
return std::make_unique<NopAudioSystem>(emulator);
|
||||
}
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
#ifndef XENIA_APU_NOP_NOP_APU_H_
|
||||
#define XENIA_APU_NOP_NOP_APU_H_
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <xenia/core.h>
|
||||
|
||||
namespace xe {
|
||||
@@ -21,7 +23,7 @@ namespace apu {
|
||||
class AudioSystem;
|
||||
namespace nop {
|
||||
|
||||
AudioSystem* Create(Emulator* emulator);
|
||||
std::unique_ptr<AudioSystem> Create(Emulator* emulator);
|
||||
|
||||
} // namespace nop
|
||||
} // namespace apu
|
||||
|
||||
@@ -11,34 +11,30 @@
|
||||
|
||||
#include <xenia/apu/xaudio2/xaudio2_audio_system.h>
|
||||
|
||||
|
||||
using namespace xe;
|
||||
using namespace xe::apu;
|
||||
using namespace xe::apu::xaudio2;
|
||||
|
||||
|
||||
namespace {
|
||||
void InitializeIfNeeded();
|
||||
void CleanupOnShutdown();
|
||||
void InitializeIfNeeded();
|
||||
void CleanupOnShutdown();
|
||||
|
||||
void InitializeIfNeeded() {
|
||||
static bool has_initialized = false;
|
||||
if (has_initialized) {
|
||||
return;
|
||||
}
|
||||
has_initialized = true;
|
||||
|
||||
//
|
||||
|
||||
atexit(CleanupOnShutdown);
|
||||
void InitializeIfNeeded() {
|
||||
static bool has_initialized = false;
|
||||
if (has_initialized) {
|
||||
return;
|
||||
}
|
||||
has_initialized = true;
|
||||
|
||||
void CleanupOnShutdown() {
|
||||
}
|
||||
//
|
||||
|
||||
atexit(CleanupOnShutdown);
|
||||
}
|
||||
|
||||
void CleanupOnShutdown() {}
|
||||
}
|
||||
|
||||
AudioSystem* xe::apu::xaudio2::Create(Emulator* emulator) {
|
||||
std::unique_ptr<AudioSystem> xe::apu::xaudio2::Create(Emulator* emulator) {
|
||||
InitializeIfNeeded();
|
||||
return new XAudio2AudioSystem(emulator);
|
||||
return std::make_unique<XAudio2AudioSystem>(emulator);
|
||||
}
|
||||
|
||||
@@ -10,24 +10,23 @@
|
||||
#ifndef XENIA_APU_XAUDIO2_XAUDIO2_APU_H_
|
||||
#define XENIA_APU_XAUDIO2_XAUDIO2_APU_H_
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <xenia/core.h>
|
||||
|
||||
|
||||
XEDECLARECLASS1(xe, Emulator);
|
||||
XEDECLARECLASS2(xe, apu, AudioSystem);
|
||||
|
||||
namespace xe {
|
||||
class Emulator;
|
||||
} // namespace xe
|
||||
|
||||
namespace xe {
|
||||
namespace apu {
|
||||
class AudioSystem;
|
||||
namespace xaudio2 {
|
||||
|
||||
|
||||
AudioSystem* Create(Emulator* emulator);
|
||||
|
||||
std::unique_ptr<AudioSystem> Create(Emulator* emulator);
|
||||
|
||||
} // namespace xaudio2
|
||||
} // namespace apu
|
||||
} // namespace xe
|
||||
|
||||
|
||||
#endif // XENIA_APU_XAUDIO2_XAUDIO2_APU_H_
|
||||
|
||||
Reference in New Issue
Block a user