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 

Crashing when going to standby mode (SDL, Mp3)

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



Joined: 21 Jul 2008
Posts: 34

PostPosted: Mon Jul 21, 2008 6:55 am    Post subject: Crashing when going to standby mode (SDL, Mp3) Reply with quote

Hi,

I'm making a mp3 player (based in early versions of lightMp3 to play the files) and I'm making the interface with SDL.

While it was only text based interface the app works fine, but after I implemented SDL the app is crashing when going to standby mode. As I searched in the forum the problem maybe is that "it's waiting for threads to sleep", I assume that this is managed by the setupcallbacks funtion, but how can this be fixed???

this is my main loop code (where I play the mp3 and show the interface):
PD:when going into the main loop there is already running the first mp3.
Code:

while(corriendo)
      {

                     sceCtrlReadBufferPositive(&pad, 1);

//////////////////////////////////////////////////////////// STOP/////////////////
                       if(pad.Buttons & PSP_CTRL_SQUARE && estado==1)
            {
                                    MP3_Stop();
               estado=0;
               MP3_End();
               MP3_Init(1);
               MP3_Load(actual);      
            }

//////////////////////////////////////////////////////////// PAUSE ////////////////
         else if(pad.Buttons & PSP_CTRL_CIRCLE && estado==1)
            {
                                    MP3_Pause();
                                 }

//////////////////////////////////////////////////////////// PLAY ALL ////////////
         else if (MP3_EndOfStream() == 1)
            {
               if(kaux->next!=NULL)
                  {
                                          MP3_Stop();
                     estado=0;
                     kaux=kaux->next;
                     strcpy(actual,kaux->ruta);
                     MP3_End();
                     MP3_Init(1);
                     MP3_Load(actual);
                     MP3_Play();
                     estado=1;
                     
                  }

               else
                  {
                     MP3_Stop();
                     estado=0;
                     kaux=cabeza;
                     strcpy(actual,kaux->ruta);
                     MP3_End();
                     MP3_Init(1);
                     MP3_Load(actual);
                                          
                  }
                                    
                          }

////////////////////////////////////////////////////////////  EXIT ////////////////
         else if(pad.Buttons & PSP_CTRL_TRIANGLE)
            {
               break;
            }

         
////////////////////////////////////////////////////////////   PLAY ///////////////
         else if(pad.Buttons & PSP_CTRL_CROSS && estado==0)
            {
               MP3_Play();
               estado=1;
                              
            }
      

////////////////////////////////////////////////////////////   PREVIOUS///////////
         else if(pad.Buttons & PSP_CTRL_LTRIGGER && kaux->before!=NULL)
            {
               MP3_Stop();
               estado=0;
               kaux=kaux->before;
               strcpy(actual,kaux->ruta);
               MP3_End();
               MP3_Init(1);
               MP3_Load(actual);
               MP3_Play();
               estado=1;
                        
            }

////////////////////////////////////////////////////////////   NEXT ///////////////
         else if(pad.Buttons & PSP_CTRL_RTRIGGER && kaux->next!=NULL)
            {
               MP3_Stop();
               estado=0;
               kaux=kaux->next;
               strcpy(actual,kaux->ruta);
               MP3_End();
               MP3_Init(1);
               MP3_Load(actual);
               MP3_Play();
               estado=1;
                                    
            }



//*****************INTERFACE *******

         SDL_BlitSurface(fondo,NULL,pantalla,NULL);


         frec=(SDL_Rect) {200,4,275,265};
         SDL_SetAlpha(lirica,SDL_SRCALPHA|SDL_RLEACCEL,180);
         SDL_BlitSurface(lirica,NULL,pantalla,&frec);

            strcpy(aclirica,kaux->lirica);
            fd=fopen(aclirica,"r");

            if(fd!=NULL)
               {            
                  lx=206;
                  ly=6;

                  while(!feof(fd))
                     {                     
                        fgets(linea,128,fd);
                        linea[strlen(linea)-2]=NULL;
                        frec=(SDL_Rect) {lx,ly,100,10};
                        txtimg=TTF_RenderText_Solid(fuente,linea,color);
                        SDL_BlitSurface(txtimg,NULL,pantalla,&frec);
                        SDL_FreeSurface(txtimg);
                        ly+=10;
                     }
                  showl=1;
                                    
               }
            fclose(fd);
         
         frec=(SDL_Rect) {0,0,100,30};
         txtimg=TTF_RenderText_Blended(fuente,kaux->nombre,color);
         SDL_BlitSurface(txtimg,NULL,pantalla,&frec);
         SDL_FreeSurface(txtimg);   

         frec=(SDL_Rect) {0,15,100,30};
         txtimg=TTF_RenderText_Blended(fuente,"O = pausa",color);
         SDL_BlitSurface(txtimg,NULL,pantalla,&frec);
         SDL_FreeSurface(txtimg);   

         frec=(SDL_Rect) {0,30,100,30};
         txtimg=TTF_RenderText_Blended(fuente,"X = play",color);
         SDL_BlitSurface(txtimg,NULL,pantalla,&frec);
         SDL_FreeSurface(txtimg);   

         frec=(SDL_Rect) {0,45,100,30};
         txtimg=TTF_RenderText_Blended(fuente,"L = anterior",color);
         SDL_BlitSurface(txtimg,NULL,pantalla,&frec);
         SDL_FreeSurface(txtimg);   

         frec=(SDL_Rect) {0,60,100,30};
         txtimg=TTF_RenderText_Blended(fuente,"R = siguiente",color);
         SDL_BlitSurface(txtimg,NULL,pantalla,&frec);
         SDL_FreeSurface(txtimg);   

         frec=(SDL_Rect) {0,75,100,30};
         txtimg=TTF_RenderText_Blended(fuente,"^ HOME = salir",color);
         SDL_BlitSurface(txtimg,NULL,pantalla,&frec);
         SDL_FreeSurface(txtimg);   

         frec=(SDL_Rect) {0,90,100,30};
         txtimg=TTF_RenderText_Blended(fuente,"Coded By Soulless",(SDL_Color) {0,0,255});
         SDL_BlitSurface(txtimg,NULL,pantalla,&frec);
         SDL_FreeSurface(txtimg);

         SDL_Flip(pantalla);         
         
      }


_________________
"Libera eas de ore leonis, ne absorbeat eas tartarus, ne cadant in obscurum"
Back to top
View user's profile Send private message
Torch



Joined: 28 May 2008
Posts: 842

PostPosted: Tue Jul 22, 2008 12:40 am    Post subject: Reply with quote

Add a sceKernelDelayThread(10); at the end of the loop and see what happens.
Back to top
View user's profile Send private message
iceman755



Joined: 21 Jul 2008
Posts: 34

PostPosted: Tue Jul 22, 2008 4:43 am    Post subject: Reply with quote

Torch wrote:
Add a sceKernelDelayThread(10); at the end of the loop and see what happens.


Thanks bro!!!

It seems that I have to read some manuals and tutorials about threads managment.
_________________
"Libera eas de ore leonis, ne absorbeat eas tartarus, ne cadant in obscurum"
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