[Qt] Setup the audio system in the factory.
This commit is contained in:
parent
398eaa565f
commit
4c99805cf2
|
@ -105,8 +105,15 @@ bool EmulatorWindow::Setup() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto audio_factory = [&](cpu::Processor* processor) {
|
auto audio_factory = [&](cpu::Processor* processor,
|
||||||
return apu::xaudio2::XAudio2AudioSystem::Create(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,
|
auto graphics_factory = [&](cpu::Processor* processor,
|
||||||
|
@ -117,14 +124,18 @@ bool EmulatorWindow::Setup() {
|
||||||
return std::unique_ptr<gpu::vulkan::VulkanGraphicsSystem>(nullptr);
|
return std::unique_ptr<gpu::vulkan::VulkanGraphicsSystem>(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
graphics->SetSwapCallback([&]() {
|
|
||||||
QMetaObject::invokeMethod(this->graphics_window_.get(), "requestUpdate",
|
|
||||||
Qt::QueuedConnection);
|
|
||||||
});
|
|
||||||
return graphics;
|
return graphics;
|
||||||
};
|
};
|
||||||
|
|
||||||
X_STATUS result = emulator_->Setup(audio_factory, graphics_factory, nullptr);
|
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;
|
return result == X_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -77,7 +77,8 @@ Emulator::~Emulator() {
|
||||||
}
|
}
|
||||||
|
|
||||||
X_STATUS Emulator::Setup(
|
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,
|
audio_system_factory,
|
||||||
std::function<std::unique_ptr<gpu::GraphicsSystem>(cpu::Processor*,
|
std::function<std::unique_ptr<gpu::GraphicsSystem>(cpu::Processor*,
|
||||||
kernel::KernelState*)>
|
kernel::KernelState*)>
|
||||||
|
@ -138,7 +139,7 @@ X_STATUS Emulator::Setup(
|
||||||
|
|
||||||
// Initialize the APU.
|
// Initialize the APU.
|
||||||
if (audio_system_factory) {
|
if (audio_system_factory) {
|
||||||
audio_system_ = audio_system_factory(processor_.get());
|
audio_system_ = audio_system_factory(processor_.get(), kernel_state_.get());
|
||||||
if (!audio_system_) {
|
if (!audio_system_) {
|
||||||
return X_STATUS_UNSUCCESSFUL;
|
return X_STATUS_UNSUCCESSFUL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -98,7 +98,8 @@ class Emulator {
|
||||||
// Once this function returns a game can be launched using one of the Launch
|
// Once this function returns a game can be launched using one of the Launch
|
||||||
// functions.
|
// functions.
|
||||||
X_STATUS Setup(
|
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,
|
audio_system_factory,
|
||||||
std::function<std::unique_ptr<gpu::GraphicsSystem>(cpu::Processor*,
|
std::function<std::unique_ptr<gpu::GraphicsSystem>(cpu::Processor*,
|
||||||
kernel::KernelState*)>
|
kernel::KernelState*)>
|
||||||
|
|
Loading…
Reference in New Issue