Mix_LoadMUS_RW in SDL_Mixer 1.2.6

Has anyone tried out Mix_LoadMUS_RW() in SDL_Mixer 1.2.6? I compiled it and mikmod with the #define USE_RWOPS, but I’ve been having troubles loading a Mix_Music*

I use a function like this to load the music…
Mix_Music *Music_Load( char * filename )
{
Mix_Music *music = NULL;
/Here I load the filename from a zip folder and read the data into a buffer - same extraction code that I use for loading WAVs with Mix_LoadWAV_RW()/
int filesize = 0;
char *buffer = Extract_File_From_Zip( filename, &filesize );
SDL_RWops *rw = SDL_RWFromMem(buffer, filesize );
music = Mix_LoadMUS_RW(rw);
SDL_FreeRW( rw );
delete [] buffer;
return music;
}

The real function checks for NULL every time I assign something to a pointer. Using MSVC, I have stepped-through the code, and music is filled with an adress to a Mix_Music. Immedietly when I go to use Mix_PlayMusic( music, -1 ), I receive an Unhandled exception Access violation, like there is a bad pointer.

Has anyone been able to get Mix_LoadMUS_RW to work? Am I doing something wrong? When I use Mix_LoadMUS() as opposed to Mix_LoadMUS_RW() everything works fine, but I would really like to be able to use Mix_LoadMUS_RW() so I can store all my game resources in a zip file.________________________________________________________________
Juno Gift Certificates
Give the gift of Internet access this holiday season.
http://www.juno.com/give

Michael Wyrzykowski wrote:

Has anyone been able to get Mix_LoadMUS_RW to work?

no… because it’s broken :slight_smile:

here is the patch: (reverted from an older, working, version)

Index: mikmod/mmio.c===================================================================
RCS file: /home/sdlweb/libsdl.org/cvs/SDL_mixer/mikmod/mmio.c,v
retrieving revision 1.5
diff -u -r1.5 mmio.c
— mikmod/mmio.c 21 Dec 2004 17:38:38 -0000 1.5
+++ mikmod/mmio.c 27 Dec 2004 01:09:29 -0000
@@ -82,7 +82,7 @@

static BOOL _mm_RWopsReader_Eof(MREADER* reader)
{

  • if ( ((MRWOPSREADER*)reader)->end ==
  • if ( ((MRWOPSREADER*)reader)->end <
    SDL_RWtell(((MRWOPSREADER*)reader)->rw) ) return 1;
    else return 0;
    }

no… because it’s broken :slight_smile:

btw this patch will fix broken rwop testing in playmus:

Index: playmus.c===================================================================
RCS file: /home/sdlweb/libsdl.org/cvs/SDL_mixer/playmus.c,v
retrieving revision 1.19
diff -u -r1.19 playmus.c
— playmus.c 21 Dec 2004 20:08:57 -0000 1.19
+++ playmus.c 27 Dec 2004 01:41:56 -0000
@@ -183,11 +183,11 @@

while (argv[i]) {
	next_track = 0;

	/* Load the requested music file */
	if ( rwops ) {
		rwfp = SDL_RWFromFile(argv[i], "rb");
  •   	music = Mix_LoadMUS(argv[i]);
    
  •   	music = Mix_LoadMUS_RW(rwfp);
      } else {
      	music = Mix_LoadMUS(argv[i]);
      }

Michael Wyrzykowski wrote:

Has anyone been able to get Mix_LoadMUS_RW to work?

no… because it’s broken :slight_smile:

here is the patch: (reverted from an older, working, version)

Index: mikmod/mmio.c

RCS file: /home/sdlweb/libsdl.org/cvs/SDL_mixer/mikmod/mmio.c,v
retrieving revision 1.5
diff -u -r1.5 mmio.c
— mikmod/mmio.c 21 Dec 2004 17:38:38 -0000 1.5
+++ mikmod/mmio.c 27 Dec 2004 01:09:29 -0000
@@ -82,7 +82,7 @@

static BOOL _mm_RWopsReader_Eof(MREADER* reader)
{

  • if ( ((MRWOPSREADER*)reader)->end ==
  • if ( ((MRWOPSREADER*)reader)->end <
    SDL_RWtell(((MRWOPSREADER*)reader)->rw) ) return 1;
    else return 0;
    }

Shouldn’t that be <= ?
We’re testing whether or not we’re at end of file, and it seems like 'end’
would be the index of the end of the file? e.g. end = 0, tell = 0 == EOF ?

See ya,
-Sam Lantinga, Software Engineer, Blizzard Entertainment

no… because it’s broken :slight_smile:

btw this patch will fix broken rwop testing in playmus:

Whoops, thanks. Committed to CVS.

See ya,
-Sam Lantinga, Software Engineer, Blizzard Entertainment

Sam Lantinga wrote:

static BOOL _mm_RWopsReader_Eof(MREADER* reader)
{

  • if ( ((MRWOPSREADER*)reader)->end ==
  • if ( ((MRWOPSREADER*)reader)->end <
    SDL_RWtell(((MRWOPSREADER*)reader)->rw) ) return 1;
    else return 0;
    }

Shouldn’t that be <= ?
We’re testing whether or not we’re at end of file, and it seems like 'end’
would be the index of the end of the file? e.g. end = 0, tell = 0 == EOF ?

I tested both, only < is working.
I just tried with a small test, and feof() return 1 only if we are
past fseek(f,0,SEEK_END). and so mikmod expect the same.

Gautier

I get a similar problem with just plain Mix_LoadMUS (SDL_mixer 1.2.6). I
don’t use MSVC so it took me forever to figure this out.

I have a native build of mingw32/msys on my windows box. If I run my
program through the msys “command prompt” I get no errors, even using
gdb nothing comes up. My code seems to be free of errors. When I run it
through the Windows GUI I get an Error like this:

The instruction at “0x7c9111cd” referenced memory at 0x00000000". The
memory could not be “read”.

However, to spur even further confusion… this only happens
sometimes… I cannot seems to reproduce it effectively the only
reproducing element i get is the “0x7c9111cd” for the function call,
wherever that is. The memory address changes… sometimes. Seems rather
bizarre, but if anyone has any ideas I’m up for them.–
John Josef
Wyled
Crazed Monkeys Inc www.crazedmonkeys.com