make cross-instance pause work without breaking local wifi connections

This commit is contained in:
Arisotura
2023-03-11 23:07:29 +01:00
parent 4e6f054ffa
commit e0955cd1d4
4 changed files with 69 additions and 45 deletions

View File

@ -197,7 +197,7 @@ EmuThread::EmuThread(QObject* parent) : QThread(parent)
connect(this, SIGNAL(swapScreensToggle()), mainWindow->actScreenSwap, SLOT(trigger()));
connect(this, SIGNAL(screenEmphasisToggle()), mainWindow, SLOT(onScreenEmphasisToggled()));
connect(this, SIGNAL(windowIPCPause()), mainWindow, SLOT(onIPCPause()));
connect(this, SIGNAL(windowIPCPause(bool)), mainWindow, SLOT(onIPCPause(bool)));
static_cast<ScreenPanelGL*>(mainWindow->panel)->transferLayout(this);
}
@ -363,8 +363,6 @@ void EmuThread::run()
{
IPC::ProcessCommands();
if (IPC::CommandReceived(IPC::Cmd_Pause)) emit windowIPCPause();
Input::Process();
if (Input::HotkeyPressed(HK_FastForwardToggle)) emit windowLimitFPSChange();
@ -678,6 +676,7 @@ void EmuThread::emuRun()
// checkme
emit windowEmuStart();
AudioInOut::Enable();
IPC::SetActive(true);
}
void EmuThread::initContext()
@ -702,6 +701,7 @@ void EmuThread::emuPause()
while (EmuStatus != emuStatus_Paused);
AudioInOut::Disable();
IPC::SetActive(false);
}
void EmuThread::emuUnpause()
@ -714,6 +714,7 @@ void EmuThread::emuUnpause()
EmuRunning = PrevEmuStatus;
AudioInOut::Enable();
IPC::SetActive(true);
}
void EmuThread::emuStop()
@ -722,12 +723,13 @@ void EmuThread::emuStop()
EmuPauseStack = EmuPauseStackRunning;
AudioInOut::Disable();
IPC::SetActive(false);
}
void EmuThread::emuFrameStep()
{
if (EmuPauseStack < EmuPauseStackPauseThreshold) emit windowEmuPause();
EmuRunning = emuStatus_FrameStep;
if (EmuRunning != 3) IPC::SetActive(false);
EmuRunning = 3;
}
bool EmuThread::emuIsRunning()
@ -2714,19 +2716,18 @@ void MainWindow::onPause(bool checked)
pausedManually = false;
}
IPC::SendCommand(0xFFFF, IPC::Cmd_Pause, 0, nullptr);
IPC::SendCommandU8(0xFFFF, IPC::Cmd_Pause, (u8)checked);
}
void MainWindow::onIPCPause()
void MainWindow::onIPCPause(bool pause)
{
// for IPC, using the normal way to trigger a pause (actPause->trigger())
// isn't viable, because it would lead to broadcasting more IPC 'pause' messages
// so we have to replicate it this way
actPause->toggle(); // changes visual state, without triggering onPause()
bool checked = actPause->isChecked();
actPause->setChecked(pause); // changes visual state, without triggering onPause()
if (checked)
if (pause)
{
emuThread->emuPause();
OSD::AddMessage(0, "Paused");