Mix_LoadMUS_RW not loading MP3s correctly

It only works if the MP3s are individual files on disk.

If I save a collection of MP3s to one large database file, seek the file to the start of one of these MP3s and load it with Mix_LoadMUS_RW and try to play it, I get a seek error from libmpg123-0.dll.

I am guessing this is because the MP3 player assumes the start of the file handle is the start of the MP3 file, which isn’t the case. Has anyone else encountered this problem? Is there a work-around?

I’m thinking I could load the MP3 into memory, create a SDL_RWops for this memory, then pass that to Mix_LoadMUS_RW? Haven’t tried yet. Wanted to hear people’s thoughts first please.

It looks like the mpg123 loader doesn’t save the original file offset for seeking. This would be pretty easy to add. Can you add a bug to bugzilla for tracking? If you attach a test case that will make it easier to verify.


1 Like

Thanks Sam, nice to know it’s an easy fix. Submitted:


I’m putting together a test.cpp & test.dat right now for you… hold tight

It looks like offsets under about 65K work no problem. So the offset is being truncated through a Uint16 maybe? Test code and data are uploaded to bugzilla for you.