Dependency injection for apu/gpu/hid.

This commit is contained in:
Ben Vanik
2015-11-08 15:02:24 -08:00
parent 9a6c5c5c74
commit 5834a42ef3
34 changed files with 217 additions and 158 deletions

View File

@@ -9,6 +9,4 @@
#include "xenia/apu/apu_flags.h"
DEFINE_string(apu, "any", "Audio system. Use: [any, nop, xaudio2]");
DEFINE_bool(mute, false, "Mutes all audio output.");

View File

@@ -12,8 +12,6 @@
#include <gflags/gflags.h>
DECLARE_string(apu);
DECLARE_bool(mute);
#endif // XENIA_APU_APU_FLAGS_H_

View File

@@ -20,11 +20,6 @@
#include "xenia/base/threading.h"
#include "xenia/cpu/thread_state.h"
#include "xenia/apu/nop/nop_audio_system.h"
#if XE_PLATFORM_WIN32
#include "xenia/apu/xaudio2/xaudio2_audio_system.h"
#endif // XE_PLATFORM_WIN32
// As with normal Microsoft, there are like twelve different ways to access
// the audio APIs. Early games use XMA*() methods almost exclusively to touch
// decoders. Later games use XAudio*() and direct memory writes to the XMA
@@ -40,29 +35,6 @@
namespace xe {
namespace apu {
std::unique_ptr<AudioSystem> AudioSystem::Create(cpu::Processor* processor) {
if (FLAGS_apu.compare("nop") == 0) {
return nop::NopAudioSystem::Create(processor);
#if XE_PLATFORM_WIN32
} else if (FLAGS_apu.compare("xaudio2") == 0) {
return xaudio2::XAudio2AudioSystem::Create(processor);
#endif // WIN32
} else {
// Create best available.
std::unique_ptr<AudioSystem> best;
#if XE_PLATFORM_WIN32
best = xaudio2::XAudio2AudioSystem::Create(processor);
if (best) {
return best;
}
#endif // XE_PLATFORM_WIN32
// Fallback to nop.
return nop::NopAudioSystem::Create(processor);
}
}
AudioSystem::AudioSystem(cpu::Processor* processor)
: memory_(processor->memory()),
processor_(processor),

View File

@@ -30,8 +30,6 @@ class AudioSystem {
public:
virtual ~AudioSystem();
static std::unique_ptr<AudioSystem> Create(cpu::Processor* processor);
Memory* memory() const { return memory_; }
cpu::Processor* processor() const { return processor_; }
XmaDecoder* xma_decoder() const { return xma_decoder_.get(); }