Freeze caused by call to sceKernelDelayThread ?

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

Moderators: cheriff, TyRaNiD

Post Reply
dridri
Posts: 34
Joined: Fri Jul 31, 2009 1:47 am

Freeze caused by call to sceKernelDelayThread ?

Post by dridri »

First, im french and 15 years old, im not a good english speaker ^^.

I have got a matter with a simple code in a thread, in this code the call to sceKernelDelayThread freeze the PSP :

Code: Select all

// This code works perfectly
while(1){
	if(!mp3->playing){
		pspDebugScreenPrintf("Not playing 00...\n");
		sceKernelDelayThread(10000);
		pspDebugScreenPrintf("Not playing 01...\n");
		continue;
	}
}


// This code freeze at sceKernelDelayThread
while(1){
	if(!mp3->playing){
		pspDebugScreenPrintf("Not playing...\n");
		sceKernelDelayThread(10000);
		pspDebugScreenPrintf("Not playing 2...\n");
		continue;
	}
	/some other code ....
	........
	......
	.......
	.. */
}
That is the same program, but there is some code following in the loop.



To be sure of this bug, i tried to launch a exception handler, the result is a BreakPoint, the adress means to be in a kernel PRX (adress cant be in my program cause its to big: 0x07.......).
My program is a simple EBOOT, compiled in PRX Mode (for 1.50+ compatibility).


Thanks !
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

It's almost certainly not the delay, but some other code doing something like overflowing a string buffer or the stack.
iceman755
Posts: 30
Joined: Mon Jul 21, 2008 1:12 am

Post by iceman755 »

I think more code will help to solve your problem, cause you are showing the same code (just diferent outputs in pspDebugScreenPrintf) and just saying this works and this doesn't.

And how do you know that is in sceKernelDelayThread where the psp freeze??? try using psplink, it will help you with errors and finding the exact line where the code crashes.
"Libera eas de ore leonis, ne absorbeat eas tartarus, ne cadant in obscurum"
dridri
Posts: 34
Joined: Fri Jul 31, 2009 1:47 am

Post by dridri »

iceman755 wrote:And how do you know that is in sceKernelDelayThread where the psp freeze??? try using psplink, it will help you with errors and finding the exact line where the code crashes.
There's the output on screen :
Not playing...
That's all, so the problem is caused on this function.

The entire code :

Code: Select all

static int MP3_Decode_Thread(int args, void *argp){
	ge_Music* mp3 = (ge_Music*)((u32*)argp)[0];
	pspDebugScreenPrintf("MP3_Decode_Thread called !\n");

	short mp3_mix_buffer[2][1152*2] __attribute__((aligned(64)));
	short mp3_output_buffer[4][1152 * 2] __attribute__((aligned(64)));
	int mp3_output_index = 0; 

	int working_buf = 0;
	int ret = 0;
	int audio_channel = sceAudioChReserve(PSP_AUDIO_NEXT_CHANNEL, 1152, PSP_AUDIO_FORMAT_STEREO);
	int frame_size = read_next_frame(mp3, working_buf);

/**********
	while(1){
		if(!mp3->playing){
			pspDebugScreenPrintf("Not playing 00...\n");
			sceKernelDelayThread(10000);
			pspDebugScreenPrintf("Not playing 01...\n");
			continue;
		}
	}
**********/

	pspDebugScreenPrintf("mp3->playing: %d\n", mp3->playing);
	while(1){
		if(!mp3->playing){
			pspDebugScreenPrintf("Not playing...\n");
			sceKernelDelayThread(10000);
			pspDebugScreenPrintf("Not playing 2...\n");
			continue;
		}
		mp3->codec_struct[6] = (unsigned long)mp3->src_buffer[working_buf];
		mp3->codec_struct[8] = (unsigned long)mp3_mix_buffer[working_buf];
		mp3->codec_struct[7] = mp3->codec_struct[10] = frame_size;
		mp3->codec_struct[9] = 1152 * 4;

		ret = sceAudiocodecDecode(mp3->codec_struct, 0x1002);

		memcpy(mp3_output_buffer[mp3_output_index], mp3_mix_buffer[working_buf], 1152*4);
		sceAudioOutputBlocking(audio_channel, mp3->hard_volume, mp3_output_buffer[mp3_output_index]);
		mp3_output_index = (mp3_output_index+1)%4; 

		memset(mp3_mix_buffer, 0, 1152*2*2);

		frame_size = read_next_frame(mp3, working_buf);
	}

	return 0;
}
It's very strange....


Else, if I cant resolve the proble, I think to do this code part in ASM...
Post Reply