Excuse me, I've coded another simple MP3 player, but when I press Circle, sometimes the PSP crash!
Only sometimes, not ever!
( I call the Music_player(char* fileName) from my main programm,
the rest works all great and the crash appens when exit the MP3_Player funct! )
Here is the code:
Code: Select all
int play(char *filename, int nextPrevious, char *numbers)
{
int retVal = 0;
SceCtrlData padd;
int action = 0;
MP3_Init(1);
MP3_Load(filename);
MP3_Play();
action = 1;
while(running())
{
sceCtrlReadBufferPositive(&padd, 1);
if(padd.Buttons & PSP_CTRL_CROSS)
{
MP3_Pause();
if (action != -1){
action = -1;
}else{
action = 1;
}
sceKernelDelayThread(400000);
}
//Controllo se l'mp3 è finito:
if (MP3_EndOfStream() == 1) {
MP3_End();
retVal = 0;
break;
}
if(padd.Buttons & PSP_CTRL_CIRCLE)
{
retVal = 2;
MP3_End();
sleep(200000);
return retVal;
}
}
return retVal;
}
void MP3_Player(char* target, int mode)
{
if (mode==1) // Play single file
{
play(target, 0, "");
sceKernelDelayThread(200000);
}
}
int Music_player(char* fileName)
{
pspDebugScreenInit();
pspDebugScreenClear();
MP3_Player(fileName, 1);
initGraphics();
return 0;
}
Why? I haven't found a possible error!