Frontend: Use configured audio backend when creating stream
This commit is contained in:
parent
16317d077e
commit
0eab6435fe
|
@ -3,6 +3,7 @@
|
||||||
#include "YBaseLib/ByteStream.h"
|
#include "YBaseLib/ByteStream.h"
|
||||||
#include "YBaseLib/Error.h"
|
#include "YBaseLib/Error.h"
|
||||||
#include "YBaseLib/Log.h"
|
#include "YBaseLib/Log.h"
|
||||||
|
#include "common/null_audio_stream.h"
|
||||||
#include "core/cdrom.h"
|
#include "core/cdrom.h"
|
||||||
#include "core/dma.h"
|
#include "core/dma.h"
|
||||||
#include "core/gpu.h"
|
#include "core/gpu.h"
|
||||||
|
@ -12,11 +13,6 @@
|
||||||
#include "core/spu.h"
|
#include "core/spu.h"
|
||||||
#include "core/system.h"
|
#include "core/system.h"
|
||||||
#include "core/timers.h"
|
#include "core/timers.h"
|
||||||
#ifdef Y_PLATFORM_WINDOWS
|
|
||||||
#include "YBaseLib/Windows/WindowsHeaders.h"
|
|
||||||
#include "d3d11_host_display.h"
|
|
||||||
#include <mmsystem.h>
|
|
||||||
#endif
|
|
||||||
#include "icon.h"
|
#include "icon.h"
|
||||||
#include "imgui_styles.h"
|
#include "imgui_styles.h"
|
||||||
#include "opengl_host_display.h"
|
#include "opengl_host_display.h"
|
||||||
|
@ -28,6 +24,12 @@
|
||||||
#include <nfd.h>
|
#include <nfd.h>
|
||||||
Log_SetChannel(SDLHostInterface);
|
Log_SetChannel(SDLHostInterface);
|
||||||
|
|
||||||
|
#ifdef Y_PLATFORM_WINDOWS
|
||||||
|
#include "YBaseLib/Windows/WindowsHeaders.h"
|
||||||
|
#include "d3d11_host_display.h"
|
||||||
|
#include <mmsystem.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
SDLHostInterface::SDLHostInterface() : m_settings_filename("settings.ini")
|
SDLHostInterface::SDLHostInterface() : m_settings_filename("settings.ini")
|
||||||
{
|
{
|
||||||
// Increase timer/sleep resolution since we use it for throttling.
|
// Increase timer/sleep resolution since we use it for throttling.
|
||||||
|
@ -123,10 +125,28 @@ void SDLHostInterface::CreateImGuiContext()
|
||||||
ImGui::AddRobotoRegularFont();
|
ImGui::AddRobotoRegularFont();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SDLHostInterface::CreateAudioStream()
|
void SDLHostInterface::CreateAudioStream()
|
||||||
{
|
{
|
||||||
m_audio_stream = std::make_unique<SDLAudioStream>();
|
switch (m_settings.audio_backend)
|
||||||
return m_audio_stream->Reconfigure(44100, 2);
|
{
|
||||||
|
case AudioBackend::Null:
|
||||||
|
m_audio_stream = std::make_unique<NullAudioStream>();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case AudioBackend::Default:
|
||||||
|
default:
|
||||||
|
m_audio_stream = std::make_unique<SDLAudioStream>();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!m_audio_stream->Reconfigure(44100, 2))
|
||||||
|
{
|
||||||
|
ReportError("Failed to recreate audio stream, falling back to null");
|
||||||
|
m_audio_stream.reset();
|
||||||
|
m_audio_stream = std::make_unique<NullAudioStream>();
|
||||||
|
if (!m_audio_stream->Reconfigure(44100, 2))
|
||||||
|
Panic("Failed to reconfigure null audio stream");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDLHostInterface::SaveSettings()
|
void SDLHostInterface::SaveSettings()
|
||||||
|
@ -181,6 +201,12 @@ void SDLHostInterface::SwitchGPURenderer()
|
||||||
ClearImGuiFocus();
|
ClearImGuiFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SDLHostInterface::SwitchAudioRenderer()
|
||||||
|
{
|
||||||
|
m_audio_stream.reset();
|
||||||
|
CreateAudioStream();
|
||||||
|
}
|
||||||
|
|
||||||
void SDLHostInterface::UpdateFullscreen()
|
void SDLHostInterface::UpdateFullscreen()
|
||||||
{
|
{
|
||||||
SDL_SetWindowFullscreen(m_window, m_settings.display_fullscreen ? SDL_WINDOW_FULLSCREEN_DESKTOP : 0);
|
SDL_SetWindowFullscreen(m_window, m_settings.display_fullscreen ? SDL_WINDOW_FULLSCREEN_DESKTOP : 0);
|
||||||
|
@ -218,11 +244,7 @@ std::unique_ptr<SDLHostInterface> SDLHostInterface::Create(const char* filename
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!intf->CreateAudioStream())
|
intf->CreateAudioStream();
|
||||||
{
|
|
||||||
Log_ErrorPrintf("Failed to create host audio stream");
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
ImGui::NewFrame();
|
ImGui::NewFrame();
|
||||||
|
|
||||||
|
|
|
@ -79,12 +79,13 @@ private:
|
||||||
bool CreateDisplay();
|
bool CreateDisplay();
|
||||||
void DestroyDisplay();
|
void DestroyDisplay();
|
||||||
void CreateImGuiContext();
|
void CreateImGuiContext();
|
||||||
bool CreateAudioStream();
|
void CreateAudioStream();
|
||||||
|
|
||||||
void SaveSettings();
|
void SaveSettings();
|
||||||
|
|
||||||
void QueueSwitchGPURenderer();
|
void QueueSwitchGPURenderer();
|
||||||
void SwitchGPURenderer();
|
void SwitchGPURenderer();
|
||||||
|
void SwitchAudioRenderer();
|
||||||
void UpdateFullscreen();
|
void UpdateFullscreen();
|
||||||
void UpdateControllerMapping();
|
void UpdateControllerMapping();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue