forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Problem with simple MP3 player!!!

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
darkness



Joined: 15 Jun 2008
Posts: 121

PostPosted: Fri Jul 18, 2008 6:25 am    Post subject: Problem with simple MP3 player!!! Reply with quote

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
View user's profile Send private message
Pirata Nervo



Joined: 09 Oct 2007
Posts: 409

PostPosted: Fri Jul 18, 2008 8:56 am    Post subject: Reply with quote

you can use sakya's players source code.
before loading another mp3.
try free the other one? :P
_________________

Upgrade your PSP
Back to top
View user's profile Send private message
darkness



Joined: 15 Jun 2008
Posts: 121

PostPosted: Sat Jul 19, 2008 3:11 am    Post subject: Reply with quote

Yes, I've already looked in the sakya src, but now I'm working on a new solution! :)
Back to top
View user's profile Send private message
darkness



Joined: 15 Jun 2008
Posts: 121

PostPosted: Sat Jul 19, 2008 5:57 am    Post subject: Reply with quote

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
View user's profile Send private message
moonlight



Joined: 26 Oct 2005
Posts: 567

PostPosted: Sat Jul 19, 2008 7:27 am    Post subject: Reply with quote

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
View user's profile Send private message
darkness



Joined: 15 Jun 2008
Posts: 121

PostPosted: Sat Jul 19, 2008 9:27 pm    Post subject: Reply with quote

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
View user's profile Send private message
k!rk



Joined: 18 Jul 2008
Posts: 11

PostPosted: Tue Jul 22, 2008 7:05 am    Post subject: Reply with quote

Try MP3_FreeTune();
Back to top
View user's profile Send private message
darkness



Joined: 15 Jun 2008
Posts: 121

PostPosted: Wed Jul 23, 2008 1:43 am    Post subject: Reply with quote

?? MP3_FreeTune is called in the MP3_End funct!
However I resolved with pause the track before call MP3_End!
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group