diff options
| author | Emma <47298336+zzEmmazz@users.noreply.github.com> | 2026-11-23 00:25:57 +0200 |
|---|---|---|
| committer | Emma <47298336+zzEmmazz@users.noreply.github.com> | 2026-11-23 00:25:57 +0200 |
| commit | 9cf23507799555d204408f8d92fd54ac88f74ba9 (patch) | |
| tree | f99d692ff677ec18264042ff4c1d1b058d4e65c6 /runtime/shims/process.cpp | |
| parent | 4de3ef85873772e1d454e37f92beabf38c1fa559 (diff) | |
| parent | aa2988cc555bad7ecd508b48a702adbb32fe7c95 (diff) | |
Merge origin/main into asset-303-awc-chunk-bd
main gained the 0xbd cue-record decoder in rsc8_audio.py (4cf7e3e7). The
section in docs/audio_config.md now points at docs/rsc8_audio.md for the
record layout and keeps what is specific to the music banks; a test holds
awc_markers.events() to rsc8_audio.decode_marker_records().
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Diffstat (limited to 'runtime/shims/process.cpp')
| -rw-r--r-- | runtime/shims/process.cpp | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/runtime/shims/process.cpp b/runtime/shims/process.cpp index 9da50e4e9..1fc4fee7f 100644 --- a/runtime/shims/process.cpp +++ b/runtime/shims/process.cpp | |||
| @@ -206,6 +206,7 @@ int run_entry(void* entry, size_t stack_bytes) { | |||
| 206 | g_exited = false; | 206 | g_exited = false; |
| 207 | g_exit_code = 0; | 207 | g_exit_code = 0; |
| 208 | g_done = CreateEventW(nullptr, TRUE, FALSE, nullptr); | 208 | g_done = CreateEventW(nullptr, TRUE, FALSE, nullptr); |
| 209 | if (!g_done) return -1; | ||
| 209 | g_running = true; | 210 | g_running = true; |
| 210 | EntryCall call{entry}; | 211 | EntryCall call{entry}; |
| 211 | HANDLE thread = CreateThread(nullptr, stack_bytes, game_thread, &call, STACK_SIZE_PARAM_IS_A_RESERVATION, nullptr); | 212 | HANDLE thread = CreateThread(nullptr, stack_bytes, game_thread, &call, STACK_SIZE_PARAM_IS_A_RESERVATION, nullptr); |
| @@ -218,7 +219,17 @@ int run_entry(void* entry, size_t stack_bytes) { | |||
| 218 | // The run ends when any game thread exits the process (exit/ExitProcess/abort) or the entry point returns. | 219 | // The run ends when any game thread exits the process (exit/ExitProcess/abort) or the entry point returns. |
| 219 | HANDLE waits[] = {g_done, thread}; | 220 | HANDLE waits[] = {g_done, thread}; |
| 220 | WaitForMultipleObjects(2, waits, FALSE, INFINITE); | 221 | WaitForMultipleObjects(2, waits, FALSE, INFINITE); |
| 221 | if (g_exited) WaitForSingleObject(g_done, 5000); | 222 | bool expected = false; |
| 223 | if (g_exited.compare_exchange_strong(expected, true)) { | ||
| 224 | // The entry thread exited without calling end_run (e.g. ExitThread); claim g_exited so no worker thread can | ||
| 225 | // touch g_done while we close it, and preserve the thread's exit code. | ||
| 226 | DWORD thread_code = 0; | ||
| 227 | if (GetExitCodeThread(thread, &thread_code)) g_exit_code = static_cast<int>(thread_code); | ||
| 228 | } else { | ||
| 229 | // Another thread already won g_exited and is publishing g_exit_code + SetEvent(g_done); wait until it finishes | ||
| 230 | // so we never close g_done or return before g_exit_code is published. | ||
| 231 | WaitForSingleObject(g_done, INFINITE); | ||
| 232 | } | ||
| 222 | CloseHandle(thread); | 233 | CloseHandle(thread); |
| 223 | CloseHandle(g_done); | 234 | CloseHandle(g_done); |
| 224 | g_done = nullptr; | 235 | g_done = nullptr; |