mirror of
https://github.com/cemu-project/Cemu.git
synced 2026-07-09 17:14:47 -06:00
coreinit: add pause/resume functionality
This commit is contained in:
parent
bd076fe70a
commit
9f72963d64
@ -448,6 +448,8 @@ namespace CafeSystem
|
||||
bool sSystemRunning = false;
|
||||
TitleId sForegroundTitleId = 0;
|
||||
|
||||
bool sTitlePaused = false;
|
||||
|
||||
GameInfo2 sGameInfo_ForegroundTitle;
|
||||
|
||||
|
||||
@ -931,6 +933,30 @@ namespace CafeSystem
|
||||
return sSystemRunning;
|
||||
}
|
||||
|
||||
void PauseTitle()
|
||||
{
|
||||
if (!sSystemRunning || sTitlePaused)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
sTitlePaused = true;
|
||||
|
||||
coreinit::SuspendActiveThreads();
|
||||
}
|
||||
|
||||
void ResumeTitle()
|
||||
{
|
||||
if (!sSystemRunning || !sTitlePaused)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
sTitlePaused = false;
|
||||
|
||||
coreinit::ResumeActiveThreads();
|
||||
}
|
||||
|
||||
TitleId GetForegroundTitleId()
|
||||
{
|
||||
cemu_assert_debug(sForegroundTitleId != 0);
|
||||
|
||||
@ -31,6 +31,9 @@ namespace CafeSystem
|
||||
void LaunchForegroundTitle();
|
||||
bool IsTitleRunning();
|
||||
|
||||
void PauseTitle();
|
||||
void ResumeTitle();
|
||||
|
||||
bool GetOverrideArgStr(std::vector<std::string>& args);
|
||||
void SetOverrideArgs(std::span<std::string> args);
|
||||
void UnsetOverrideArgs();
|
||||
|
||||
@ -94,6 +94,42 @@ namespace coreinit
|
||||
uint32 selectedCore;
|
||||
};
|
||||
|
||||
void SuspendActiveThreads()
|
||||
{
|
||||
if (activeThreadCount == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
__OSLockScheduler();
|
||||
|
||||
for (sint32 i = 0; i < activeThreadCount; i++)
|
||||
{
|
||||
auto thread = reinterpret_cast<OSThread_t*>(memory_getPointerFromVirtualOffset(activeThread[i]));
|
||||
__OSSuspendThreadNolock(thread);
|
||||
}
|
||||
|
||||
__OSUnlockScheduler();
|
||||
}
|
||||
|
||||
void ResumeActiveThreads()
|
||||
{
|
||||
if (activeThreadCount == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
__OSLockScheduler();
|
||||
|
||||
for (sint32 i = 0; i < activeThreadCount; i++)
|
||||
{
|
||||
auto thread = reinterpret_cast<OSThread_t*>(memory_getPointerFromVirtualOffset(activeThread[i]));
|
||||
__OSResumeThreadInternal(thread, 1);
|
||||
}
|
||||
|
||||
__OSUnlockScheduler();
|
||||
}
|
||||
|
||||
std::unordered_map<OSThread_t*, OSHostThread*> s_threadToFiber;
|
||||
|
||||
bool __CemuIsMulticoreMode()
|
||||
|
||||
@ -508,6 +508,9 @@ namespace coreinit
|
||||
|
||||
void InitializeConcurrency();
|
||||
|
||||
void SuspendActiveThreads();
|
||||
void ResumeActiveThreads();
|
||||
|
||||
bool __CemuIsMulticoreMode();
|
||||
|
||||
OSThread_t* OSGetDefaultThread(sint32 coreIndex);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user