Keep hanging on exit

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
User avatar
wich
Posts: 13
Joined: Wed Feb 14, 2007 6:05 am

Keep hanging on exit

Post by wich »

Hi people,

I keep having problems with my app hanging on exit, I get the "Please wait..." screen and it just never quits. I have tried adding the sceKernelDisplayWaitVblankStart() and sceKernelDelayThread(0) before and after sceKernelExitGame() but that didn't change anything. I've tried putting sceKernelExitGame in the exit callback function, but that didn't help. Now I've been trying to gracefully clean up the callback function and threads, but that doesn't seem to relieve the problem either. I've included the code I currently have below, I have run out of ideas and after going through 20 pages of the psp dev forum I haven't found anything to help me, (The search function is unavailable atm.) Could anybody say what I'm doing wrong, or what I could do to resolve the issue?

Code: Select all

#include <pspkernel.h>
#include <pspdisplay.h>
#include <pspdebug.h>

PSP_MODULE_INFO&#40;"Test v1.0", 0, 1, 1&#41;;
PSP_MAIN_THREAD_ATTR&#40;THREAD_ATTR_USER&#41;;

bool done = false;

int exit_callback&#40;int arg1, int arg2, void* common&#41; &#123;
	done = true;
	return 0;
&#125;

int callback_thread&#40;SceSize args, void* argp&#41; &#123;
	int cbid ;
		
	cbid = sceKernelCreateCallback&#40;"Exit Callback", exit_callback, 0&#41;;
	sceKernelRegisterExitCallback&#40;cbid&#41;;

	sceKernelSleepThreadCB&#40;&#41;;

	return cbid;
&#125;

int setup_callbacks&#40;&#41; &#123;
	int thid = 0;
	thid = sceKernelCreateThread&#40;"update_thread", callback_thread, 0x11, 0xFA0, THREAD_ATTR_USER, 0&#41;;

	if &#40;0 <= thid&#41;
		sceKernelStartThread&#40;thid, 0, 0&#41;;

	return thid;
&#125;

void deinit_callbacks&#40;int thid&#41; &#123;
	sceKernelWakeupThread&#40;thid&#41;;
	sceKernelWaitThreadEnd&#40;thid, 0&#41;;
	int cbid = sceKernelGetThreadExitStatus&#40;thid&#41;;
	//sceKernelUnregisterExitCallback&#40;&#41;;
	sceKernelDeleteCallback&#40;cbid&#41;;
	sceKernelDeleteThread&#40;thid&#41;;
&#125;

int main&#40;int argc, char** argv&#41; &#123;
	int cb_thread = setup_callbacks&#40;&#41;;

	while &#40;!done&#41; &#123;
	&#125;

	deinit_callbacks&#40;cb_thread&#41;;

	sceDisplayWaitVblankStart&#40;&#41;;
	sceKernelExitGame&#40;&#41;;
	sceKernelDelayThread&#40;0&#41;;
	sceKernelExitThread&#40;0&#41;;

	return 0;
&#125;
Post Reply