Welcome! Log In Create A New Profile

Advanced

MP3Player

Posted by wilco2009 
MP3Player
May 28, 2011 05:17PM
Hi all.
I'm doing a game with some mp3 samples as ambient music, but I found a problem.
My code is something like that:

ASND_Init();
MP3Player_Init();
buffer_size = GRRLIB_Loadfile("0.mp3", &buffer);
MP3Player_PlayBuffer(buffer, buffer_size, NULL);
while(1){

    ......
     ......
     some code
     .......
     .......
     if (!MP3Player_IsPlaying()){
         MP3Player_Stop();
         free(buffer);
         buffer_size = GRRLIB_Loadfile("other.mp3", &buffer);
         MP3Player_PlayBuffer(buffer, buffer_size, NULL);     
     }
}

Unfortunely, after some calls to MP3Player_Stop(), program hangs. I was tried everithing I thought but at the end I convert the files to ogg format and I used the ogg player library.

Somwbody knows if there are a known bug in the library, or what is the problem in my code?



Edited 1 time(s). Last edit at 05/28/2011 05:44PM by wilco2009.
Re: MP3Player
May 28, 2011 08:55PM
Why are you using GRRLIB_Loadfile to load the file? Just wondering. Don't know anything about that function but I'd think you'd need to free the buffer after use.

Also how big is the buffer and the file you are loading? Unless your mp3's are small I would not recommend loading the whole file into mem. Set up a buffering system and pre-buffer a little then read chunks using the read callback.

The mp3 functions are temperamental and unless you know what you are doing or really need the file as an mp3 I believe the ogg library works much cleaner.

FYI: - Arikado made a little tutorial on how to load a file into mem. this.

[arikadosblog.blogspot.com]
Sorry, only registered users may post in this forum.

Click here to login