Merge pull request #11165 from AdmiralCurtiss/audiocommon-pass-system

AudioCommon: Pass Core::System to AudioCommon functions.
This commit is contained in:
Mai
2022-11-23 04:49:31 +00:00
committed by GitHub
8 changed files with 55 additions and 54 deletions

View File

@ -448,7 +448,7 @@ static void FifoPlayerThread(const std::optional<std::string>& savestate_path,
// See the BootManager.cpp file description for a complete call schedule.
static void EmuThread(std::unique_ptr<BootParameters> boot, WindowSystemInfo wsi)
{
const Core::System& system = Core::System::GetInstance();
Core::System& system = Core::System::GetInstance();
const SConfig& core_parameter = SConfig::GetInstance();
CallOnStateChangedCallbacks(State::Starting);
Common::ScopeGuard flag_guard{[] {
@ -505,8 +505,8 @@ static void EmuThread(std::unique_ptr<BootParameters> boot, WindowSystemInfo wsi
Movie::Init(*boot);
Common::ScopeGuard movie_guard{&Movie::Shutdown};
AudioCommon::InitSoundStream();
Common::ScopeGuard audio_guard{&AudioCommon::ShutdownSoundStream};
AudioCommon::InitSoundStream(system);
Common::ScopeGuard audio_guard([&system] { AudioCommon::ShutdownSoundStream(system); });
HW::Init(NetPlay::IsNetPlayRunning() ? &(boot_session_data.GetNetplaySettings()->sram) : nullptr);
@ -558,7 +558,7 @@ static void EmuThread(std::unique_ptr<BootParameters> boot, WindowSystemInfo wsi
// it's now ok to initialize any custom textures
HiresTexture::Update();
AudioCommon::PostInitSoundStream();
AudioCommon::PostInitSoundStream(system);
// The hardware is initialized.
s_hardware_initialized = true;

View File

@ -14,6 +14,7 @@
#include "Core/Host.h"
#include "Core/PowerPC/GDBStub.h"
#include "Core/PowerPC/PowerPC.h"
#include "Core/System.h"
#include "VideoCommon/Fifo.h"
namespace CPU
@ -193,7 +194,7 @@ static void RunAdjacentSystems(bool running)
Fifo::EmulatorState(running);
// Core is responsible for shutting down the sound stream.
if (s_state != State::PowerDown)
AudioCommon::SetSoundStreamRunning(running);
AudioCommon::SetSoundStreamRunning(Core::System::GetInstance(), running);
}
void Stop()

View File

@ -414,7 +414,8 @@ void RegisterMMIO(MMIO::Mapping* mmio, u32 base)
mmio->Register(
base | AUDIO_DMA_CONTROL_LEN, MMIO::DirectRead<u16>(&state.audio_dma.AudioDMAControl.Hex),
MMIO::ComplexWrite<u16>([](u32, u16 val) {
auto& state = Core::System::GetInstance().GetDSPState().GetData();
auto& system = Core::System::GetInstance();
auto& state = system.GetDSPState().GetData();
bool already_enabled = state.audio_dma.AudioDMAControl.Enable;
state.audio_dma.AudioDMAControl.Hex = val;
@ -522,7 +523,7 @@ void UpdateAudioDMA()
// external audio fifo in the emulator, to be mixed with the disc
// streaming output.
void* address = Memory::GetPointer(state.audio_dma.current_source_address);
AudioCommon::SendAIBuffer(reinterpret_cast<short*>(address), 8);
AudioCommon::SendAIBuffer(system, reinterpret_cast<short*>(address), 8);
if (state.audio_dma.remaining_blocks_count != 0)
{
@ -540,7 +541,7 @@ void UpdateAudioDMA()
}
else
{
AudioCommon::SendAIBuffer(&zero_samples[0], 8);
AudioCommon::SendAIBuffer(system, &zero_samples[0], 8);
}
}