Frontend: Add audio backend to settings (switch-while-running)
This commit is contained in:
parent
0eab6435fe
commit
5bb2b3ec63
|
@ -21,7 +21,6 @@ SPU::~SPU() = default;
|
||||||
|
|
||||||
void SPU::Initialize(System* system, DMA* dma, InterruptController* interrupt_controller)
|
void SPU::Initialize(System* system, DMA* dma, InterruptController* interrupt_controller)
|
||||||
{
|
{
|
||||||
m_audio_stream = system->GetHostInterface()->GetAudioStream();
|
|
||||||
m_system = system;
|
m_system = system;
|
||||||
m_dma = dma;
|
m_dma = dma;
|
||||||
m_interrupt_controller = interrupt_controller;
|
m_interrupt_controller = interrupt_controller;
|
||||||
|
@ -109,7 +108,7 @@ bool SPU::DoState(StateWrapper& sw)
|
||||||
sw.DoBytes(m_ram.data(), RAM_SIZE);
|
sw.DoBytes(m_ram.data(), RAM_SIZE);
|
||||||
|
|
||||||
if (sw.IsReading())
|
if (sw.IsReading())
|
||||||
m_audio_stream->EmptyBuffers();
|
m_system->GetHostInterface()->GetAudioStream()->EmptyBuffers();
|
||||||
|
|
||||||
return !sw.HasError();
|
return !sw.HasError();
|
||||||
}
|
}
|
||||||
|
@ -1006,7 +1005,7 @@ void SPU::GenerateSample()
|
||||||
std::array<AudioStream::SampleType, 2> out_samples;
|
std::array<AudioStream::SampleType, 2> out_samples;
|
||||||
out_samples[0] = Clamp16(ApplyVolume(left_sum, m_main_volume_left.GetVolume()));
|
out_samples[0] = Clamp16(ApplyVolume(left_sum, m_main_volume_left.GetVolume()));
|
||||||
out_samples[1] = Clamp16(ApplyVolume(right_sum, m_main_volume_right.GetVolume()));
|
out_samples[1] = Clamp16(ApplyVolume(right_sum, m_main_volume_right.GetVolume()));
|
||||||
m_audio_stream->WriteSamples(out_samples.data(), 1);
|
m_system->GetHostInterface()->GetAudioStream()->WriteSamples(out_samples.data(), 1);
|
||||||
|
|
||||||
// Write to capture buffers.
|
// Write to capture buffers.
|
||||||
WriteToCaptureBuffer(0, cd_audio_left);
|
WriteToCaptureBuffer(0, cd_audio_left);
|
||||||
|
|
|
@ -287,7 +287,6 @@ private:
|
||||||
System* m_system = nullptr;
|
System* m_system = nullptr;
|
||||||
DMA* m_dma = nullptr;
|
DMA* m_dma = nullptr;
|
||||||
InterruptController* m_interrupt_controller = nullptr;
|
InterruptController* m_interrupt_controller = nullptr;
|
||||||
AudioStream* m_audio_stream = nullptr;
|
|
||||||
|
|
||||||
SPUCNT m_SPUCNT = {};
|
SPUCNT m_SPUCNT = {};
|
||||||
SPUSTAT m_SPUSTAT = {};
|
SPUSTAT m_SPUSTAT = {};
|
||||||
|
|
|
@ -201,10 +201,16 @@ void SDLHostInterface::SwitchGPURenderer()
|
||||||
ClearImGuiFocus();
|
ClearImGuiFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDLHostInterface::SwitchAudioRenderer()
|
void SDLHostInterface::SwitchAudioBackend()
|
||||||
{
|
{
|
||||||
m_audio_stream.reset();
|
m_audio_stream.reset();
|
||||||
CreateAudioStream();
|
CreateAudioStream();
|
||||||
|
|
||||||
|
if (m_system)
|
||||||
|
{
|
||||||
|
m_audio_stream->PauseOutput(false);
|
||||||
|
UpdateSpeedLimiterState();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDLHostInterface::UpdateFullscreen()
|
void SDLHostInterface::UpdateFullscreen()
|
||||||
|
@ -1162,14 +1168,26 @@ void SDLHostInterface::DrawSettingsWindow()
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::NewLine();
|
ImGui::NewLine();
|
||||||
if (DrawSettingsSectionHeader("Host Synchronization"))
|
if (DrawSettingsSectionHeader("Audio"))
|
||||||
{
|
{
|
||||||
if (ImGui::Checkbox("Sync To Audio", &m_settings.audio_sync_enabled))
|
ImGui::Text("Backend:");
|
||||||
|
ImGui::SameLine(indent);
|
||||||
|
|
||||||
|
int backend = static_cast<int>(m_settings.audio_backend);
|
||||||
|
if (ImGui::Combo(
|
||||||
|
"##backend", &backend,
|
||||||
|
[](void*, int index, const char** out_text) {
|
||||||
|
*out_text = Settings::GetAudioBackendDisplayName(static_cast<AudioBackend>(index));
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
nullptr, static_cast<int>(AudioBackend::Count)))
|
||||||
{
|
{
|
||||||
|
m_settings.audio_backend = static_cast<AudioBackend>(backend);
|
||||||
settings_changed = true;
|
settings_changed = true;
|
||||||
UpdateSpeedLimiterState();
|
SwitchAudioBackend();
|
||||||
}
|
}
|
||||||
if (ImGui::Checkbox("Sync To Video", &m_settings.video_sync_enabled))
|
|
||||||
|
if (ImGui::Checkbox("Output Sync", &m_settings.audio_sync_enabled))
|
||||||
{
|
{
|
||||||
settings_changed = true;
|
settings_changed = true;
|
||||||
UpdateSpeedLimiterState();
|
UpdateSpeedLimiterState();
|
||||||
|
@ -1292,6 +1310,12 @@ void SDLHostInterface::DrawSettingsWindow()
|
||||||
m_display->SetDisplayLinearFiltering(m_settings.display_linear_filtering);
|
m_display->SetDisplayLinearFiltering(m_settings.display_linear_filtering);
|
||||||
settings_changed = true;
|
settings_changed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ImGui::Checkbox("VSync", &m_settings.video_sync_enabled))
|
||||||
|
{
|
||||||
|
settings_changed = true;
|
||||||
|
UpdateSpeedLimiterState();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::NewLine();
|
ImGui::NewLine();
|
||||||
|
|
|
@ -85,7 +85,7 @@ private:
|
||||||
|
|
||||||
void QueueSwitchGPURenderer();
|
void QueueSwitchGPURenderer();
|
||||||
void SwitchGPURenderer();
|
void SwitchGPURenderer();
|
||||||
void SwitchAudioRenderer();
|
void SwitchAudioBackend();
|
||||||
void UpdateFullscreen();
|
void UpdateFullscreen();
|
||||||
void UpdateControllerMapping();
|
void UpdateControllerMapping();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue