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:
PJB3005
2026-04-07 20:06:29 +02:00
parent ee5ab7978e
commit 63ade15e2c
9 changed files with 47 additions and 6 deletions
+15 -6
View File
@@ -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) {