aboutsummaryrefslogtreecommitdiff
path: root/backends/platform/wii
diff options
context:
space:
mode:
authorAndre Heider2009-02-15 15:39:44 +0000
committerAndre Heider2009-02-15 15:39:44 +0000
commit4d4cabba0a90b4e96098c20cb02b17b0b0930f26 (patch)
tree93cd92a7b0f5fc733e0a627871b14e3f98ee887e /backends/platform/wii
parent3a6da187ad5984ccbfad04873acd8293fc42098f (diff)
downloadscummvm-rg350-4d4cabba0a90b4e96098c20cb02b17b0b0930f26.tar.gz
scummvm-rg350-4d4cabba0a90b4e96098c20cb02b17b0b0930f26.tar.bz2
scummvm-rg350-4d4cabba0a90b4e96098c20cb02b17b0b0930f26.zip
better error checking when setting up threads, and free() the stacks when done.
svn-id: r38260
Diffstat (limited to 'backends/platform/wii')
-rw-r--r--backends/platform/wii/osystem_events.cpp23
-rw-r--r--backends/platform/wii/osystem_sfx.cpp24
2 files changed, 27 insertions, 20 deletions
diff --git a/backends/platform/wii/osystem_events.cpp b/backends/platform/wii/osystem_events.cpp
index 4646da8c93..7597bd65db 100644
--- a/backends/platform/wii/osystem_events.cpp
+++ b/backends/platform/wii/osystem_events.cpp
@@ -117,20 +117,22 @@ void OSystem_Wii::initEvents() {
timer_thread_quit = false;
timer_stack = (u8 *) memalign(32, TIMER_THREAD_STACKSIZE);
- memset(timer_stack, 0, TIMER_THREAD_STACKSIZE);
+ if (timer_stack) {
+ memset(timer_stack, 0, TIMER_THREAD_STACKSIZE);
- LWP_InitQueue(&timer_queue);
+ LWP_InitQueue(&timer_queue);
- s32 res = LWP_CreateThread(&timer_thread, timer_thread_func, NULL,
- timer_stack, TIMER_THREAD_STACKSIZE,
- TIMER_THREAD_PRIO);
+ s32 res = LWP_CreateThread(&timer_thread, timer_thread_func, NULL,
+ timer_stack, TIMER_THREAD_STACKSIZE,
+ TIMER_THREAD_PRIO);
- if (res) {
- printf("ERROR creating timer thread: %d\n", res);
- LWP_CloseQueue(timer_queue);
- }
+ if (res) {
+ printf("ERROR creating timer thread: %d\n", res);
+ LWP_CloseQueue(timer_queue);
+ }
- timer_thread_running = res == 0;
+ timer_thread_running = res == 0;
+ }
#ifndef GAMECUBE
WPAD_Init();
@@ -151,6 +153,7 @@ void OSystem_Wii::deinitEvents() {
LWP_JoinThread(timer_thread, NULL);
LWP_CloseQueue(timer_queue);
+ free(timer_stack);
timer_thread_running = false;
}
diff --git a/backends/platform/wii/osystem_sfx.cpp b/backends/platform/wii/osystem_sfx.cpp
index 0a225e80c7..6af6958c32 100644
--- a/backends/platform/wii/osystem_sfx.cpp
+++ b/backends/platform/wii/osystem_sfx.cpp
@@ -69,20 +69,23 @@ void OSystem_Wii::initSfx() {
sfx_thread_quit = false;
sfx_stack = (u8 *) memalign(32, SFX_THREAD_STACKSIZE);
- memset(sfx_stack, 0, SFX_THREAD_STACKSIZE);
- LWP_InitQueue(&sfx_queue);
+ if (sfx_stack) {
+ memset(sfx_stack, 0, SFX_THREAD_STACKSIZE);
- s32 res = LWP_CreateThread(&sfx_thread, sfx_thread_func, _mixer, sfx_stack,
- SFX_THREAD_STACKSIZE, SFX_THREAD_PRIO);
+ LWP_InitQueue(&sfx_queue);
- if (res) {
- printf("ERROR creating sfx thread: %d\n", res);
- LWP_CloseQueue(sfx_queue);
- return;
- }
+ s32 res = LWP_CreateThread(&sfx_thread, sfx_thread_func, _mixer, sfx_stack,
+ SFX_THREAD_STACKSIZE, SFX_THREAD_PRIO);
- sfx_thread_running = true;
+ if (res) {
+ printf("ERROR creating sfx thread: %d\n", res);
+ LWP_CloseQueue(sfx_queue);
+ return;
+ }
+
+ sfx_thread_running = true;
+ }
sound_buffer[0] = (u8 *) memalign(32, SFX_THREAD_FRAG_SIZE);
sound_buffer[1] = (u8 *) memalign(32, SFX_THREAD_FRAG_SIZE);
@@ -116,6 +119,7 @@ void OSystem_Wii::deinitSfx() {
LWP_JoinThread(sfx_thread, NULL);
LWP_CloseQueue(sfx_queue);
+ free(sfx_stack);
sfx_thread_running = false;
free(sound_buffer[0]);