| View previous topic :: View next topic |
| Author |
Message |
darkness
Joined: 15 Jun 2008 Posts: 121
|
Posted: Fri Jul 18, 2008 6:25 am Post subject: Problem with simple MP3 player!!! |
|
|
I have to load with a function a MP3 file everytime that I want it, so I've writed it:
| Code: |
int Music_player(char* fileName)
{
if(inited==1){ MP3_End(); inited=0; }
MP3_Init(1);
MP3_Load(fileName);
MP3_Play();
inited=1;
return 0;
}
|
But with this func I can't load more than 1 file, ( if I try to load more files the psp crash!!! )...
However if there is another simple MP3 lib I can use it! ( But I don't know other simple lib ) :(! |
|
| Back to top |
|
 |
Pirata Nervo
Joined: 09 Oct 2007 Posts: 409
|
Posted: Fri Jul 18, 2008 8:56 am Post subject: |
|
|
you can use sakya's players source code.
before loading another mp3.
try free the other one? :P _________________
Upgrade your PSP |
|
| Back to top |
|
 |
darkness
Joined: 15 Jun 2008 Posts: 121
|
Posted: Sat Jul 19, 2008 3:11 am Post subject: |
|
|
| Yes, I've already looked in the sakya src, but now I'm working on a new solution! :) |
|
| Back to top |
|
 |
darkness
Joined: 15 Jun 2008 Posts: 121
|
Posted: Sat Jul 19, 2008 5:57 am Post subject: |
|
|
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: |
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! |
|
| Back to top |
|
 |
moonlight
Joined: 26 Oct 2005 Posts: 567
|
Posted: Sat Jul 19, 2008 7:27 am Post subject: |
|
|
Have you tried to detect exactly in which function crashes?
With that info, it is not possible to say if it is crashing hapens when calling initGraphics(); or if maybe it happens later when returning to your main app. |
|
| Back to top |
|
 |
darkness
Joined: 15 Jun 2008 Posts: 121
|
Posted: Sat Jul 19, 2008 9:27 pm Post subject: |
|
|
I've tryied to put a simple printf after the MP3_Player call and after MP3_End();
The printf after the MP3_Player call is not executed and the one after MP3_End(); is executed! |
|
| Back to top |
|
 |
k!rk
Joined: 18 Jul 2008 Posts: 11
|
Posted: Tue Jul 22, 2008 7:05 am Post subject: |
|
|
| Try MP3_FreeTune(); |
|
| Back to top |
|
 |
darkness
Joined: 15 Jun 2008 Posts: 121
|
Posted: Wed Jul 23, 2008 1:43 am Post subject: |
|
|
?? MP3_FreeTune is called in the MP3_End funct!
However I resolved with pause the track before call MP3_End! |
|
| Back to top |
|
 |
|