mirror of
https://github.com/DarkMatterCore/nxdumptool.git
synced 2024-11-08 11:51:48 +00:00
gamecard: add smarter delay to detection thread
Lets us respond in a better way to sudden gamecard status changes during the 3 second wait period.
This commit is contained in:
parent
ec993864fd
commit
56053e8105
1 changed files with 20 additions and 8 deletions
|
@ -695,17 +695,29 @@ static void gamecardDetectionThreadFunc(void *arg)
|
||||||
/* Free gamecard info before proceeding. */
|
/* Free gamecard info before proceeding. */
|
||||||
gamecardFreeInfo(true);
|
gamecardFreeInfo(true);
|
||||||
|
|
||||||
/* Retrieve current gamecard insertion status. */
|
/* Delay gamecard access by GAMECARD_ACCESS_DELAY full seconds. This is done to to avoid conflicts with HOS / sysmodules. */
|
||||||
/* Only proceed if we're dealing with a status change. */
|
/* We will periodically check if the gamecard is still inserted during this period. */
|
||||||
if (gamecardIsInserted())
|
/* If the gamecard is taken out before reaching the length of the delay, we won't try to access it. */
|
||||||
{
|
time_t start = time(NULL);
|
||||||
/* Don't access the gamecard immediately to avoid conflicts with HOS / sysmodules. */
|
bool gc_delay_passed = false;
|
||||||
utilsSleep(GAMECARD_ACCESS_DELAY);
|
|
||||||
|
|
||||||
/* Load gamecard info. */
|
while(gamecardIsInserted())
|
||||||
gamecardLoadInfo();
|
{
|
||||||
|
time_t now = time(NULL);
|
||||||
|
time_t diff = (now - start);
|
||||||
|
|
||||||
|
if (diff >= GAMECARD_ACCESS_DELAY)
|
||||||
|
{
|
||||||
|
gc_delay_passed = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
utilsAppletLoopDelay();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Load gamecard info (if applicable). */
|
||||||
|
if (gc_delay_passed) gamecardLoadInfo();
|
||||||
|
|
||||||
/* Signal user mode gamecard status change event. */
|
/* Signal user mode gamecard status change event. */
|
||||||
ueventSignal(&g_gameCardStatusChangeEvent);
|
ueventSignal(&g_gameCardStatusChangeEvent);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue