Are you streaming the music or loading it into memory first?
Ok, here's the deal...
I have a menu before my game starts with a song playing. Then I have my game with a different song playing (with gamestates seperating the two).
When you select "Start Game" in the menu, it stops the title song and loads one for the game before changing gamestates. If you're in the game and press start to select "Return To Menu", it stops the game song and reloads the title music... Then changes gamestates again.
My problem is around 50% of the time, it freezes when changing between gamestates that load music. The "Paused" gamestate works perfectly fine because it plays the same music as the game (untill you tell it to return to the menu).
I took out every function that has to do with playing/loading OGG files, and I didn't have any problems what-so-ever. So I know the issue is with playing or loading the music.
Any help would be appreciated!!!
Well, I do Ogg.load() to load it, then Ogg.play() when I want to play it... But it seems like it's streaming it anyway. There's no load time and the memory card light is constantly flashing.
if you have enough free memory , try loading both Oggs during initialisation
rather than during gameplay.
Otherwise, making the garbage collector more aggressive may help.
I don't load them during gameplay at all. I load the song for the actual game right after you press X on "Start Game" in the menu.
It wouldn't matter either way though, because it's aparently streaming them. I could put Ogg.load() in the game code 20 times and it wouldn't slow down at all.
It's working perfectly with .XM files, but I'd much rather use .OGG if it's possible.
well, it looks like the streaming ogg's overloading lua then.
theres a few things you can try:
song = song or ogg:load(songFile) --to avoid memory leak
Change all locals to globals to reduce pressure on the stack.
When gamestate changes, song = nil , immediately followed by a full garbage collection cycle
Reduce the framerate
Add a System.sleep() into your main loop to give the streaming more CPU.
Increase CPU speed
Ultimately tho, you'll avoid no end of hassles by using a non-streaming format.
There are currently 1 users browsing this thread. (0 members and 1 guests)