Merge pull request #4684 from lioncash/dsp-emu

DSPEmulator: Amend variable casing
This commit is contained in:
Matthew Parlane 2017-01-19 09:10:58 +13:00 committed by GitHub
commit f94bd7d865
5 changed files with 164 additions and 164 deletions

View File

@ -19,14 +19,14 @@ public:
virtual void Shutdown() = 0; virtual void Shutdown() = 0;
virtual void DoState(PointerWrap& p) = 0; virtual void DoState(PointerWrap& p) = 0;
virtual void PauseAndLock(bool doLock, bool unpauseOnUnlock = true) = 0; virtual void PauseAndLock(bool do_lock, bool unpause_on_unlock = true) = 0;
virtual void DSP_WriteMailBoxHigh(bool _CPUMailbox, unsigned short) = 0; virtual void DSP_WriteMailBoxHigh(bool cpu_mailbox, u16 value) = 0;
virtual void DSP_WriteMailBoxLow(bool _CPUMailbox, unsigned short) = 0; virtual void DSP_WriteMailBoxLow(bool cpu_mailbox, u16 value) = 0;
virtual unsigned short DSP_ReadMailBoxHigh(bool _CPUMailbox) = 0; virtual u16 DSP_ReadMailBoxHigh(bool cpu_mailbox) = 0;
virtual unsigned short DSP_ReadMailBoxLow(bool _CPUMailbox) = 0; virtual u16 DSP_ReadMailBoxLow(bool cpu_mailbox) = 0;
virtual unsigned short DSP_ReadControlRegister() = 0; virtual u16 DSP_ReadControlRegister() = 0;
virtual unsigned short DSP_WriteControlRegister(unsigned short) = 0; virtual u16 DSP_WriteControlRegister(u16 value) = 0;
virtual void DSP_Update(int cycles) = 0; virtual void DSP_Update(int cycles) = 0;
virtual void DSP_StopSoundStream() = 0; virtual void DSP_StopSoundStream() = 0;
virtual u32 DSP_UpdateRate() = 0; virtual u32 DSP_UpdateRate() = 0;

View File

@ -23,16 +23,16 @@ DSPHLE::DSPHLE()
bool DSPHLE::Initialize(bool wii, bool dsp_thread) bool DSPHLE::Initialize(bool wii, bool dsp_thread)
{ {
m_wii = wii; m_wii = wii;
m_pUCode = nullptr; m_ucode = nullptr;
m_lastUCode = nullptr; m_last_ucode = nullptr;
m_bHalt = false; m_halt = false;
m_bAssertInt = false; m_assert_interrupt = false;
SetUCode(UCODE_ROM); SetUCode(UCODE_ROM);
m_DSPControl.DSPHalt = 1; m_dsp_control.DSPHalt = 1;
m_DSPControl.DSPInit = 1; m_dsp_control.DSPInit = 1;
m_dspState.Reset(); m_dsp_state.Reset();
return true; return true;
} }
@ -43,14 +43,14 @@ void DSPHLE::DSP_StopSoundStream()
void DSPHLE::Shutdown() void DSPHLE::Shutdown()
{ {
delete m_pUCode; delete m_ucode;
m_pUCode = nullptr; m_ucode = nullptr;
} }
void DSPHLE::DSP_Update(int cycles) void DSPHLE::DSP_Update(int cycles)
{ {
if (m_pUCode != nullptr) if (m_ucode != nullptr)
m_pUCode->Update(); m_ucode->Update();
} }
u32 DSPHLE::DSP_UpdateRate() u32 DSPHLE::DSP_UpdateRate()
@ -60,56 +60,56 @@ u32 DSPHLE::DSP_UpdateRate()
return SystemTimers::GetTicksPerSecond() / 1000; return SystemTimers::GetTicksPerSecond() / 1000;
} }
void DSPHLE::SendMailToDSP(u32 _uMail) void DSPHLE::SendMailToDSP(u32 mail)
{ {
if (m_pUCode != nullptr) if (m_ucode != nullptr)
{ {
DEBUG_LOG(DSP_MAIL, "CPU writes 0x%08x", _uMail); DEBUG_LOG(DSP_MAIL, "CPU writes 0x%08x", mail);
m_pUCode->HandleMail(_uMail); m_ucode->HandleMail(mail);
} }
} }
UCodeInterface* DSPHLE::GetUCode() UCodeInterface* DSPHLE::GetUCode()
{ {
return m_pUCode; return m_ucode;
} }
void DSPHLE::SetUCode(u32 _crc) void DSPHLE::SetUCode(u32 crc)
{ {
delete m_pUCode; delete m_ucode;
m_pUCode = nullptr; m_ucode = nullptr;
m_MailHandler.Clear(); m_mail_handler.Clear();
m_pUCode = UCodeFactory(_crc, this, m_wii); m_ucode = UCodeFactory(crc, this, m_wii);
m_pUCode->Initialize(); m_ucode->Initialize();
} }
// TODO do it better? // TODO do it better?
// Assumes that every odd call to this func is by the persistent ucode. // Assumes that every odd call to this func is by the persistent ucode.
// Even callers are deleted. // Even callers are deleted.
void DSPHLE::SwapUCode(u32 _crc) void DSPHLE::SwapUCode(u32 crc)
{ {
m_MailHandler.Clear(); m_mail_handler.Clear();
if (m_lastUCode == nullptr) if (m_last_ucode == nullptr)
{ {
m_lastUCode = m_pUCode; m_last_ucode = m_ucode;
m_pUCode = UCodeFactory(_crc, this, m_wii); m_ucode = UCodeFactory(crc, this, m_wii);
m_pUCode->Initialize(); m_ucode->Initialize();
} }
else else
{ {
delete m_pUCode; delete m_ucode;
m_pUCode = m_lastUCode; m_ucode = m_last_ucode;
m_lastUCode = nullptr; m_last_ucode = nullptr;
} }
} }
void DSPHLE::DoState(PointerWrap& p) void DSPHLE::DoState(PointerWrap& p)
{ {
bool isHLE = true; bool is_hle = true;
p.Do(isHLE); p.Do(is_hle);
if (isHLE != true && p.GetMode() == PointerWrap::MODE_READ) if (!is_hle && p.GetMode() == PointerWrap::MODE_READ)
{ {
Core::DisplayMessage("State is incompatible with current DSP engine. Aborting load state.", Core::DisplayMessage("State is incompatible with current DSP engine. Aborting load state.",
3000); 3000);
@ -117,33 +117,33 @@ void DSPHLE::DoState(PointerWrap& p)
return; return;
} }
p.DoPOD(m_DSPControl); p.DoPOD(m_dsp_control);
p.DoPOD(m_dspState); p.DoPOD(m_dsp_state);
int ucode_crc = UCodeInterface::GetCRC(m_pUCode); int ucode_crc = UCodeInterface::GetCRC(m_ucode);
int ucode_crc_beforeLoad = ucode_crc; int ucode_crc_beforeLoad = ucode_crc;
int lastucode_crc = UCodeInterface::GetCRC(m_lastUCode); int last_ucode_crc = UCodeInterface::GetCRC(m_last_ucode);
int lastucode_crc_beforeLoad = lastucode_crc; int last_ucode_crc_before_load = last_ucode_crc;
p.Do(ucode_crc); p.Do(ucode_crc);
p.Do(lastucode_crc); p.Do(last_ucode_crc);
// if a different type of ucode was being used when the savestate was created, // if a different type of ucode was being used when the savestate was created,
// we have to reconstruct the old type of ucode so that we have a valid thing to call DoState on. // we have to reconstruct the old type of ucode so that we have a valid thing to call DoState on.
UCodeInterface* ucode = UCodeInterface* ucode =
(ucode_crc == ucode_crc_beforeLoad) ? m_pUCode : UCodeFactory(ucode_crc, this, m_wii); (ucode_crc == ucode_crc_beforeLoad) ? m_ucode : UCodeFactory(ucode_crc, this, m_wii);
UCodeInterface* lastucode = (lastucode_crc != lastucode_crc_beforeLoad) ? UCodeInterface* last_ucode = (last_ucode_crc != last_ucode_crc_before_load) ?
m_lastUCode : m_last_ucode :
UCodeFactory(lastucode_crc, this, m_wii); UCodeFactory(last_ucode_crc, this, m_wii);
if (ucode) if (ucode)
ucode->DoState(p); ucode->DoState(p);
if (lastucode) if (last_ucode)
lastucode->DoState(p); last_ucode->DoState(p);
// if a different type of ucode was being used when the savestate was created, // if a different type of ucode was being used when the savestate was created,
// discard it if we're not loading, otherwise discard the old one and keep the new one. // discard it if we're not loading, otherwise discard the old one and keep the new one.
if (ucode != m_pUCode) if (ucode != m_ucode)
{ {
if (p.GetMode() != PointerWrap::MODE_READ) if (p.GetMode() != PointerWrap::MODE_READ)
{ {
@ -151,32 +151,32 @@ void DSPHLE::DoState(PointerWrap& p)
} }
else else
{ {
delete m_pUCode; delete m_ucode;
m_pUCode = ucode; m_ucode = ucode;
} }
} }
if (lastucode != m_lastUCode) if (last_ucode != m_last_ucode)
{ {
if (p.GetMode() != PointerWrap::MODE_READ) if (p.GetMode() != PointerWrap::MODE_READ)
{ {
delete lastucode; delete last_ucode;
} }
else else
{ {
delete m_lastUCode; delete m_last_ucode;
m_lastUCode = lastucode; m_last_ucode = last_ucode;
} }
} }
m_MailHandler.DoState(p); m_mail_handler.DoState(p);
} }
// Mailbox functions // Mailbox functions
unsigned short DSPHLE::DSP_ReadMailBoxHigh(bool _CPUMailbox) u16 DSPHLE::DSP_ReadMailBoxHigh(bool cpu_mailbox)
{ {
if (_CPUMailbox) if (cpu_mailbox)
{ {
return (m_dspState.CPUMailbox >> 16) & 0xFFFF; return (m_dsp_state.cpu_mailbox >> 16) & 0xFFFF;
} }
else else
{ {
@ -184,11 +184,11 @@ unsigned short DSPHLE::DSP_ReadMailBoxHigh(bool _CPUMailbox)
} }
} }
unsigned short DSPHLE::DSP_ReadMailBoxLow(bool _CPUMailbox) u16 DSPHLE::DSP_ReadMailBoxLow(bool cpu_mailbox)
{ {
if (_CPUMailbox) if (cpu_mailbox)
{ {
return m_dspState.CPUMailbox & 0xFFFF; return m_dsp_state.cpu_mailbox & 0xFFFF;
} }
else else
{ {
@ -196,60 +196,60 @@ unsigned short DSPHLE::DSP_ReadMailBoxLow(bool _CPUMailbox)
} }
} }
void DSPHLE::DSP_WriteMailBoxHigh(bool _CPUMailbox, unsigned short _Value) void DSPHLE::DSP_WriteMailBoxHigh(bool cpu_mailbox, u16 value)
{ {
if (_CPUMailbox) if (cpu_mailbox)
{ {
m_dspState.CPUMailbox = (m_dspState.CPUMailbox & 0xFFFF) | (_Value << 16); m_dsp_state.cpu_mailbox = (m_dsp_state.cpu_mailbox & 0xFFFF) | (value << 16);
} }
else else
{ {
PanicAlert("CPU can't write %08x to DSP mailbox", _Value); PanicAlert("CPU can't write %08x to DSP mailbox", value);
} }
} }
void DSPHLE::DSP_WriteMailBoxLow(bool _CPUMailbox, unsigned short _Value) void DSPHLE::DSP_WriteMailBoxLow(bool cpu_mailbox, u16 value)
{ {
if (_CPUMailbox) if (cpu_mailbox)
{ {
m_dspState.CPUMailbox = (m_dspState.CPUMailbox & 0xFFFF0000) | _Value; m_dsp_state.cpu_mailbox = (m_dsp_state.cpu_mailbox & 0xFFFF0000) | value;
SendMailToDSP(m_dspState.CPUMailbox); SendMailToDSP(m_dsp_state.cpu_mailbox);
// Mail sent so clear MSB to show that it is progressed // Mail sent so clear MSB to show that it is progressed
m_dspState.CPUMailbox &= 0x7FFFFFFF; m_dsp_state.cpu_mailbox &= 0x7FFFFFFF;
} }
else else
{ {
PanicAlert("CPU can't write %08x to DSP mailbox", _Value); PanicAlert("CPU can't write %08x to DSP mailbox", value);
} }
} }
// Other DSP functions // Other DSP functions
u16 DSPHLE::DSP_WriteControlRegister(unsigned short _Value) u16 DSPHLE::DSP_WriteControlRegister(u16 value)
{ {
DSP::UDSPControl Temp(_Value); DSP::UDSPControl temp(value);
if (Temp.DSPReset) if (temp.DSPReset)
{ {
SetUCode(UCODE_ROM); SetUCode(UCODE_ROM);
Temp.DSPReset = 0; temp.DSPReset = 0;
} }
if (Temp.DSPInit == 0) if (temp.DSPInit == 0)
{ {
// copy 128 byte from ARAM 0x000000 to IMEM // copy 128 byte from ARAM 0x000000 to IMEM
SetUCode(UCODE_INIT_AUDIO_SYSTEM); SetUCode(UCODE_INIT_AUDIO_SYSTEM);
Temp.DSPInitCode = 0; temp.DSPInitCode = 0;
} }
m_DSPControl.Hex = Temp.Hex; m_dsp_control.Hex = temp.Hex;
return m_DSPControl.Hex; return m_dsp_control.Hex;
} }
u16 DSPHLE::DSP_ReadControlRegister() u16 DSPHLE::DSP_ReadControlRegister()
{ {
return m_DSPControl.Hex; return m_dsp_control.Hex;
} }
void DSPHLE::PauseAndLock(bool doLock, bool unpauseOnUnlock) void DSPHLE::PauseAndLock(bool do_lock, bool unpause_on_unlock)
{ {
} }
} // namespace HLE } // namespace HLE

View File

@ -26,51 +26,51 @@ public:
void Shutdown() override; void Shutdown() override;
bool IsLLE() override { return false; } bool IsLLE() override { return false; }
void DoState(PointerWrap& p) override; void DoState(PointerWrap& p) override;
void PauseAndLock(bool doLock, bool unpauseOnUnlock = true) override; void PauseAndLock(bool do_lock, bool unpause_on_unlock = true) override;
void DSP_WriteMailBoxHigh(bool _CPUMailbox, unsigned short) override; void DSP_WriteMailBoxHigh(bool cpu_mailbox, u16 value) override;
void DSP_WriteMailBoxLow(bool _CPUMailbox, unsigned short) override; void DSP_WriteMailBoxLow(bool cpu_mailbox, u16 value) override;
unsigned short DSP_ReadMailBoxHigh(bool _CPUMailbox) override; u16 DSP_ReadMailBoxHigh(bool cpu_mailbox) override;
unsigned short DSP_ReadMailBoxLow(bool _CPUMailbox) override; u16 DSP_ReadMailBoxLow(bool cpu_mailbox) override;
unsigned short DSP_ReadControlRegister() override; u16 DSP_ReadControlRegister() override;
unsigned short DSP_WriteControlRegister(unsigned short) override; u16 DSP_WriteControlRegister(u16 value) override;
void DSP_Update(int cycles) override; void DSP_Update(int cycles) override;
void DSP_StopSoundStream() override; void DSP_StopSoundStream() override;
u32 DSP_UpdateRate() override; u32 DSP_UpdateRate() override;
CMailHandler& AccessMailHandler() { return m_MailHandler; } CMailHandler& AccessMailHandler() { return m_mail_handler; }
// Formerly DSPHandler // Formerly DSPHandler
UCodeInterface* GetUCode(); UCodeInterface* GetUCode();
void SetUCode(u32 _crc); void SetUCode(u32 crc);
void SwapUCode(u32 _crc); void SwapUCode(u32 crc);
private: private:
void SendMailToDSP(u32 _uMail); void SendMailToDSP(u32 mail);
// Fake mailbox utility // Fake mailbox utility
struct DSPState struct DSPState
{ {
u32 CPUMailbox; u32 cpu_mailbox;
u32 DSPMailbox; u32 dsp_mailbox;
void Reset() void Reset()
{ {
CPUMailbox = 0x00000000; cpu_mailbox = 0x00000000;
DSPMailbox = 0x00000000; dsp_mailbox = 0x00000000;
} }
DSPState() { Reset(); } DSPState() { Reset(); }
}; };
DSPState m_dspState; DSPState m_dsp_state;
UCodeInterface* m_pUCode; UCodeInterface* m_ucode;
UCodeInterface* m_lastUCode; UCodeInterface* m_last_ucode;
DSP::UDSPControl m_DSPControl; DSP::UDSPControl m_dsp_control;
CMailHandler m_MailHandler; CMailHandler m_mail_handler;
bool m_bHalt; bool m_halt;
bool m_bAssertInt; bool m_assert_interrupt;
}; };
} // namespace HLE } // namespace HLE
} // namespace DSP } // namespace DSP

View File

@ -31,9 +31,9 @@ namespace DSP
{ {
namespace LLE namespace LLE
{ {
static Common::Event dspEvent; static Common::Event s_dsp_event;
static Common::Event ppcEvent; static Common::Event s_ppc_event;
static bool requestDisableThread; static bool s_request_disable_thread;
DSPLLE::DSPLLE() = default; DSPLLE::DSPLLE() = default;
@ -83,12 +83,12 @@ void DSPLLE::DSPThread(DSPLLE* dsp_lle)
{ {
Common::SetCurrentThreadName("DSP thread"); Common::SetCurrentThreadName("DSP thread");
while (dsp_lle->m_bIsRunning.IsSet()) while (dsp_lle->m_is_running.IsSet())
{ {
const int cycles = static_cast<int>(dsp_lle->m_cycle_count.load()); const int cycles = static_cast<int>(dsp_lle->m_cycle_count.load());
if (cycles > 0) if (cycles > 0)
{ {
std::lock_guard<std::mutex> dsp_thread_lock(dsp_lle->m_csDSPThreadActive); std::lock_guard<std::mutex> dsp_thread_lock(dsp_lle->m_dsp_thread_mutex);
if (g_dsp_jit) if (g_dsp_jit)
{ {
DSPCore_RunCycles(cycles); DSPCore_RunCycles(cycles);
@ -101,8 +101,8 @@ void DSPLLE::DSPThread(DSPLLE* dsp_lle)
} }
else else
{ {
ppcEvent.Set(); s_ppc_event.Set();
dspEvent.Wait(); s_dsp_event.Wait();
} }
} }
} }
@ -156,7 +156,7 @@ static bool FillDSPInitOptions(DSPInitOptions* opts)
bool DSPLLE::Initialize(bool wii, bool dsp_thread) bool DSPLLE::Initialize(bool wii, bool dsp_thread)
{ {
requestDisableThread = false; s_request_disable_thread = false;
DSPInitOptions opts; DSPInitOptions opts;
if (!FillDSPInitOptions(&opts)) if (!FillDSPInitOptions(&opts))
@ -169,7 +169,7 @@ bool DSPLLE::Initialize(bool wii, bool dsp_thread)
dsp_thread = false; dsp_thread = false;
m_wii = wii; m_wii = wii;
m_bDSPThread = dsp_thread; m_is_dsp_on_thread = dsp_thread;
// DSPLLE directly accesses the fastmem arena. // DSPLLE directly accesses the fastmem arena.
// TODO: The fastmem arena is only supposed to be used by the JIT: // TODO: The fastmem arena is only supposed to be used by the JIT:
@ -181,8 +181,8 @@ bool DSPLLE::Initialize(bool wii, bool dsp_thread)
if (dsp_thread) if (dsp_thread)
{ {
m_bIsRunning.Set(true); m_is_running.Set(true);
m_hDSPThread = std::thread(DSPThread, this); m_dsp_thread = std::thread(DSPThread, this);
} }
Host_RefreshDSPDebuggerWindow(); Host_RefreshDSPDebuggerWindow();
@ -191,12 +191,12 @@ bool DSPLLE::Initialize(bool wii, bool dsp_thread)
void DSPLLE::DSP_StopSoundStream() void DSPLLE::DSP_StopSoundStream()
{ {
if (m_bDSPThread) if (m_is_dsp_on_thread)
{ {
m_bIsRunning.Clear(); m_is_running.Clear();
ppcEvent.Set(); s_ppc_event.Set();
dspEvent.Set(); s_dsp_event.Set();
m_hDSPThread.join(); m_dsp_thread.join();
} }
} }
@ -205,13 +205,13 @@ void DSPLLE::Shutdown()
DSPCore_Shutdown(); DSPCore_Shutdown();
} }
u16 DSPLLE::DSP_WriteControlRegister(u16 _uFlag) u16 DSPLLE::DSP_WriteControlRegister(u16 value)
{ {
DSP::Interpreter::WriteCR(_uFlag); DSP::Interpreter::WriteCR(value);
if (_uFlag & 2) if (value & 2)
{ {
if (!m_bDSPThread) if (!m_is_dsp_on_thread)
{ {
DSPCore_CheckExternalInterrupt(); DSPCore_CheckExternalInterrupt();
DSPCore_CheckExceptions(); DSPCore_CheckExceptions();
@ -220,7 +220,7 @@ u16 DSPLLE::DSP_WriteControlRegister(u16 _uFlag)
{ {
// External interrupt pending: this is the zelda ucode. // External interrupt pending: this is the zelda ucode.
// Disable the DSP thread because there is no performance gain. // Disable the DSP thread because there is no performance gain.
requestDisableThread = true; s_request_disable_thread = true;
DSPCore_SetExternalInterrupt(true); DSPCore_SetExternalInterrupt(true);
} }
@ -234,19 +234,19 @@ u16 DSPLLE::DSP_ReadControlRegister()
return DSP::Interpreter::ReadCR(); return DSP::Interpreter::ReadCR();
} }
u16 DSPLLE::DSP_ReadMailBoxHigh(bool _CPUMailbox) u16 DSPLLE::DSP_ReadMailBoxHigh(bool cpu_mailbox)
{ {
return gdsp_mbox_read_h(_CPUMailbox ? MAILBOX_CPU : MAILBOX_DSP); return gdsp_mbox_read_h(cpu_mailbox ? MAILBOX_CPU : MAILBOX_DSP);
} }
u16 DSPLLE::DSP_ReadMailBoxLow(bool _CPUMailbox) u16 DSPLLE::DSP_ReadMailBoxLow(bool cpu_mailbox)
{ {
return gdsp_mbox_read_l(_CPUMailbox ? MAILBOX_CPU : MAILBOX_DSP); return gdsp_mbox_read_l(cpu_mailbox ? MAILBOX_CPU : MAILBOX_DSP);
} }
void DSPLLE::DSP_WriteMailBoxHigh(bool _CPUMailbox, u16 _uHighMail) void DSPLLE::DSP_WriteMailBoxHigh(bool cpu_mailbox, u16 value)
{ {
if (_CPUMailbox) if (cpu_mailbox)
{ {
if (gdsp_mbox_peek(MAILBOX_CPU) & 0x80000000) if (gdsp_mbox_peek(MAILBOX_CPU) & 0x80000000)
{ {
@ -254,13 +254,13 @@ void DSPLLE::DSP_WriteMailBoxHigh(bool _CPUMailbox, u16 _uHighMail)
} }
#if PROFILE #if PROFILE
if ((_uHighMail) == 0xBABE) if (value == 0xBABE)
{ {
ProfilerStart(); ProfilerStart();
} }
#endif #endif
gdsp_mbox_write_h(MAILBOX_CPU, _uHighMail); gdsp_mbox_write_h(MAILBOX_CPU, value);
} }
else else
{ {
@ -268,11 +268,11 @@ void DSPLLE::DSP_WriteMailBoxHigh(bool _CPUMailbox, u16 _uHighMail)
} }
} }
void DSPLLE::DSP_WriteMailBoxLow(bool _CPUMailbox, u16 _uLowMail) void DSPLLE::DSP_WriteMailBoxLow(bool cpu_mailbox, u16 value)
{ {
if (_CPUMailbox) if (cpu_mailbox)
{ {
gdsp_mbox_write_l(MAILBOX_CPU, _uLowMail); gdsp_mbox_write_l(MAILBOX_CPU, value);
} }
else else
{ {
@ -305,19 +305,19 @@ void DSPLLE::DSP_Update(int cycles)
soundStream->Update(); soundStream->Update();
} }
*/ */
if (m_bDSPThread) if (m_is_dsp_on_thread)
{ {
if (requestDisableThread || Core::g_want_determinism) if (s_request_disable_thread || Core::g_want_determinism)
{ {
DSP_StopSoundStream(); DSP_StopSoundStream();
m_bDSPThread = false; m_is_dsp_on_thread = false;
requestDisableThread = false; s_request_disable_thread = false;
SConfig::GetInstance().bDSPThread = false; SConfig::GetInstance().bDSPThread = false;
} }
} }
// If we're not on a thread, run cycles here. // If we're not on a thread, run cycles here.
if (!m_bDSPThread) if (!m_is_dsp_on_thread)
{ {
// ~1/6th as many cycles as the period PPC-side. // ~1/6th as many cycles as the period PPC-side.
DSPCore_RunCycles(dsp_cycles); DSPCore_RunCycles(dsp_cycles);
@ -325,9 +325,9 @@ void DSPLLE::DSP_Update(int cycles)
else else
{ {
// Wait for DSP thread to complete its cycle. Note: this logic should be thought through. // Wait for DSP thread to complete its cycle. Note: this logic should be thought through.
ppcEvent.Wait(); s_ppc_event.Wait();
m_cycle_count.fetch_add(dsp_cycles); m_cycle_count.fetch_add(dsp_cycles);
dspEvent.Set(); s_dsp_event.Set();
} }
} }
@ -336,12 +336,12 @@ u32 DSPLLE::DSP_UpdateRate()
return 12600; // TO BE TWEAKED return 12600; // TO BE TWEAKED
} }
void DSPLLE::PauseAndLock(bool doLock, bool unpauseOnUnlock) void DSPLLE::PauseAndLock(bool do_lock, bool unpause_on_unlock)
{ {
if (doLock) if (do_lock)
m_csDSPThreadActive.lock(); m_dsp_thread_mutex.lock();
else else
m_csDSPThreadActive.unlock(); m_dsp_thread_mutex.unlock();
} }
} // namespace LLE } // namespace LLE
} // namespace DSP } // namespace DSP

View File

@ -27,25 +27,25 @@ public:
void Shutdown() override; void Shutdown() override;
bool IsLLE() override { return true; } bool IsLLE() override { return true; }
void DoState(PointerWrap& p) override; void DoState(PointerWrap& p) override;
void PauseAndLock(bool doLock, bool unpauseOnUnlock = true) override; void PauseAndLock(bool do_lock, bool unpause_on_unlock = true) override;
void DSP_WriteMailBoxHigh(bool _CPUMailbox, unsigned short) override; void DSP_WriteMailBoxHigh(bool cpu_mailbox, u16 value) override;
void DSP_WriteMailBoxLow(bool _CPUMailbox, unsigned short) override; void DSP_WriteMailBoxLow(bool cpu_mailbox, u16 value) override;
unsigned short DSP_ReadMailBoxHigh(bool _CPUMailbox) override; u16 DSP_ReadMailBoxHigh(bool cpu_mailbox) override;
unsigned short DSP_ReadMailBoxLow(bool _CPUMailbox) override; u16 DSP_ReadMailBoxLow(bool cpu_mailbox) override;
unsigned short DSP_ReadControlRegister() override; u16 DSP_ReadControlRegister() override;
unsigned short DSP_WriteControlRegister(unsigned short) override; u16 DSP_WriteControlRegister(u16 value) override;
void DSP_Update(int cycles) override; void DSP_Update(int cycles) override;
void DSP_StopSoundStream() override; void DSP_StopSoundStream() override;
u32 DSP_UpdateRate() override; u32 DSP_UpdateRate() override;
private: private:
static void DSPThread(DSPLLE* lpParameter); static void DSPThread(DSPLLE* dsp_lle);
std::thread m_hDSPThread; std::thread m_dsp_thread;
std::mutex m_csDSPThreadActive; std::mutex m_dsp_thread_mutex;
bool m_bDSPThread = false; bool m_is_dsp_on_thread = false;
Common::Flag m_bIsRunning; Common::Flag m_is_running;
std::atomic<u32> m_cycle_count{}; std::atomic<u32> m_cycle_count{};
}; };
} // namespace LLE } // namespace LLE