summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDr. Chat <arkolbed@gmail.com>2018-05-14 20:08:02 -0500
committerDr. Chat <arkolbed@gmail.com>2018-10-12 14:54:03 -0500
commit4c99805cf23c777a11b632477e058b146c11fed4 (patch)
tree1f26db72b2ee29296f08b618db6a626555733319
parent398eaa565fec42084928bc73517b00a4847eb4aa (diff)
[Qt] Setup the audio system in the factory.
-rw-r--r--src/xenia/app/emulator_window.cc23
-rw-r--r--src/xenia/emulator.cc5
-rw-r--r--src/xenia/emulator.h3
3 files changed, 22 insertions, 9 deletions
diff --git a/src/xenia/app/emulator_window.cc b/src/xenia/app/emulator_window.cc
index 79cb97311..87d21120c 100644
--- a/src/xenia/app/emulator_window.cc
+++ b/src/xenia/app/emulator_window.cc
@@ -105,8 +105,15 @@ bool EmulatorWindow::Setup() {
return false;
}
- auto audio_factory = [&](cpu::Processor* processor) {
- return apu::xaudio2::XAudio2AudioSystem::Create(processor);
+ auto audio_factory = [&](cpu::Processor* processor,
+ kernel::KernelState* kernel_state) {
+ auto audio = apu::xaudio2::XAudio2AudioSystem::Create(processor);
+ if (audio->Setup(kernel_state) != X_STATUS_SUCCESS) {
+ audio->Shutdown();
+ return std::unique_ptr<apu::AudioSystem>(nullptr);
+ }
+
+ return audio;
};
auto graphics_factory = [&](cpu::Processor* processor,
@@ -117,14 +124,18 @@ bool EmulatorWindow::Setup() {
return std::unique_ptr<gpu::vulkan::VulkanGraphicsSystem>(nullptr);
}
- graphics->SetSwapCallback([&]() {
- QMetaObject::invokeMethod(this->graphics_window_.get(), "requestUpdate",
- Qt::QueuedConnection);
- });
return graphics;
};
X_STATUS result = emulator_->Setup(audio_factory, graphics_factory, nullptr);
+ if (result == X_STATUS_SUCCESS) {
+ // Setup a callback called when the emulator wants to swap.
+ emulator_->graphics_system()->SetSwapCallback([&]() {
+ QMetaObject::invokeMethod(this->graphics_window_.get(), "requestUpdate",
+ Qt::QueuedConnection);
+ });
+ }
+
return result == X_STATUS_SUCCESS;
}
diff --git a/src/xenia/emulator.cc b/src/xenia/emulator.cc
index 97e7fc635..83130da4a 100644
--- a/src/xenia/emulator.cc
+++ b/src/xenia/emulator.cc
@@ -77,7 +77,8 @@ Emulator::~Emulator() {
}
X_STATUS Emulator::Setup(
- std::function<std::unique_ptr<apu::AudioSystem>(cpu::Processor*)>
+ std::function<std::unique_ptr<apu::AudioSystem>(cpu::Processor*,
+ kernel::KernelState*)>
audio_system_factory,
std::function<std::unique_ptr<gpu::GraphicsSystem>(cpu::Processor*,
kernel::KernelState*)>
@@ -138,7 +139,7 @@ X_STATUS Emulator::Setup(
// Initialize the APU.
if (audio_system_factory) {
- audio_system_ = audio_system_factory(processor_.get());
+ audio_system_ = audio_system_factory(processor_.get(), kernel_state_.get());
if (!audio_system_) {
return X_STATUS_UNSUCCESSFUL;
}
diff --git a/src/xenia/emulator.h b/src/xenia/emulator.h
index f59ae69d4..c04ce89a9 100644
--- a/src/xenia/emulator.h
+++ b/src/xenia/emulator.h
@@ -98,7 +98,8 @@ class Emulator {
// Once this function returns a game can be launched using one of the Launch
// functions.
X_STATUS Setup(
- std::function<std::unique_ptr<apu::AudioSystem>(cpu::Processor*)>
+ std::function<std::unique_ptr<apu::AudioSystem>(cpu::Processor*,
+ kernel::KernelState*)>
audio_system_factory,
std::function<std::unique_ptr<gpu::GraphicsSystem>(cpu::Processor*,
kernel::KernelState*)>