mirror of
https://github.com/TwilitRealm/dusklight
synced 2026-05-23 14:41:33 -04:00
Cleanly shut down JKRDecomp thread
Properly join the thread to ensure it's shut down before we try to exit. Fixes #268
This commit is contained in:
@@ -15,6 +15,9 @@ void my_SysPrintHeap(char const*, void*, u32);
|
||||
void mDoMch_HeapCheckAll();
|
||||
void mDoMch_HeapFreeFillAll();
|
||||
int mDoMch_Create();
|
||||
#if TARGET_PC
|
||||
void mDoMch_Destroy();
|
||||
#endif
|
||||
|
||||
extern GXRenderModeObj g_ntscZeldaProg;
|
||||
|
||||
|
||||
@@ -33,6 +33,9 @@ struct JFWSystem {
|
||||
|
||||
static void firstInit();
|
||||
static void init();
|
||||
#if TARGET_PC
|
||||
static void shutdown();
|
||||
#endif
|
||||
|
||||
static JUTConsole* getSystemConsole() { return systemConsole; }
|
||||
static JKRExpHeap* getSystemHeap() { return systemHeap; }
|
||||
|
||||
@@ -39,6 +39,9 @@ public:
|
||||
|
||||
public:
|
||||
static JKRAram* create(u32, u32, s32, s32, s32);
|
||||
#if TARGET_PC
|
||||
static void destroy();
|
||||
#endif
|
||||
static void checkOkAddress(u8*, u32, JKRAramBlock*, u32);
|
||||
static void changeGroupIdIfNeed(u8*, int);
|
||||
static JKRAramBlock* mainRamToAram(u8*, u32, u32, JKRExpandSwitch, u32, JKRHeap*, int, u32*);
|
||||
|
||||
@@ -48,6 +48,9 @@ private:
|
||||
|
||||
public:
|
||||
static JKRDecomp* create(s32);
|
||||
#if TARGET_PC
|
||||
static void destroy();
|
||||
#endif
|
||||
static JKRDecompCommand* prepareCommand(u8*, u8*, u32, u32, JKRDecompCommand::AsyncCallback);
|
||||
static void sendCommand(JKRDecompCommand*);
|
||||
static bool sync(JKRDecompCommand*, int);
|
||||
|
||||
@@ -116,3 +116,9 @@ void JFWSystem::init() {
|
||||
void* buffer = systemHeap->alloc(CSetUpParam::exConsoleBufferSize, 4);
|
||||
JUTException::createConsole(buffer, CSetUpParam::exConsoleBufferSize);
|
||||
}
|
||||
|
||||
#if TARGET_PC
|
||||
void JFWSystem::shutdown() {
|
||||
JKRAram::destroy();
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -42,6 +42,12 @@ JKRAram* JKRAram::create(u32 aram_audio_buffer_size, u32 aram_audio_graph_size,
|
||||
return sAramObject;
|
||||
}
|
||||
|
||||
#if TARGET_PC
|
||||
void JKRAram::destroy() {
|
||||
JKRDecomp::destroy();
|
||||
}
|
||||
#endif
|
||||
|
||||
OSMessage JKRAram::sMessageBuffer[4] = {
|
||||
NULL,
|
||||
NULL,
|
||||
|
||||
@@ -20,6 +20,15 @@ JKRDecomp* JKRDecomp::create(s32 priority) {
|
||||
return sDecompObject;
|
||||
}
|
||||
|
||||
#if TARGET_PC
|
||||
void JKRDecomp::destroy() {
|
||||
if (sDecompObject) {
|
||||
OSSendMessage(&sMessageQueue, nullptr, OS_MESSAGE_NOBLOCK);
|
||||
OSJoinThread(sDecompObject->getThreadRecord(), nullptr);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
OSMessage JKRDecomp::sMessageBuffer[8] = {0};
|
||||
|
||||
OSMessageQueue JKRDecomp::sMessageQueue = {0};
|
||||
@@ -34,15 +43,15 @@ void* JKRDecomp::run() {
|
||||
OSInitMessageQueue(&sMessageQueue, sMessageBuffer, 8);
|
||||
for (;;) {
|
||||
OSMessage message;
|
||||
#ifdef TARGET_PC
|
||||
if (!OSReceiveMessage(&sMessageQueue, &message, OS_MESSAGE_BLOCK)) {
|
||||
break;
|
||||
}
|
||||
#else
|
||||
OSReceiveMessage(&sMessageQueue, &message, OS_MESSAGE_BLOCK);
|
||||
#endif
|
||||
|
||||
JKRDecompCommand* command = (JKRDecompCommand*)message;
|
||||
#if TARGET_PC
|
||||
if (!command) {
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
decode(command->mSrcBuffer, command->mDstBuffer, command->mSrcLength, command->mDstLength);
|
||||
|
||||
if (command->field_0x20 != 0) {
|
||||
|
||||
@@ -1010,3 +1010,9 @@ int mDoMch_Create() {
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
#if TARGET_PC
|
||||
void mDoMch_Destroy() {
|
||||
JFWSystem::shutdown();
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -366,6 +366,8 @@ int game_main(int argc, char* argv[]) {
|
||||
fflush(stdout);
|
||||
fflush(stderr);
|
||||
|
||||
mDoMch_Destroy();
|
||||
|
||||
// Notifies all CVs and causes threads to exit
|
||||
OSResetSystem(OS_RESET_SHUTDOWN, 0, 0);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user