Problem with simple MP3 player!!!

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

Moderators: cheriff, TyRaNiD

Post Reply
darkness
Posts: 121
Joined: Sun Jun 15, 2008 8:42 pm

Problem with simple MP3 player!!!

Post by darkness »

I have to load with a function a MP3 file everytime that I want it, so I've writed it:

Code: Select all

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 ) :(!
Pirata Nervo
Posts: 409
Joined: Tue Oct 09, 2007 4:22 am

Post by Pirata Nervo »

you can use sakya's players source code.
before loading another mp3.
try free the other one? :P
Image
Upgrade your PSP
darkness
Posts: 121
Joined: Sun Jun 15, 2008 8:42 pm

Post by darkness »

Yes, I've already looked in the sakya src, but now I'm working on a new solution! :)
darkness
Posts: 121
Joined: Sun Jun 15, 2008 8:42 pm

Post by darkness »

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!
moonlight
Posts: 567
Joined: Wed Oct 26, 2005 7:46 pm

Post by moonlight »

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.
darkness
Posts: 121
Joined: Sun Jun 15, 2008 8:42 pm

Post by darkness »

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!
k!rk
Posts: 11
Joined: Fri Jul 18, 2008 8:26 am

Post by k!rk »

Try MP3_FreeTune();
darkness
Posts: 121
Joined: Sun Jun 15, 2008 8:42 pm

Post by darkness »

?? MP3_FreeTune is called in the MP3_End funct!
However I resolved with pause the track before call MP3_End!
Post Reply