music_mod.c
branchSDL-1.2
changeset 865 3ffb22a2755b
parent 542 3de4970b36d4
equal deleted inserted replaced
864:c8dc1ec196f5 865:3ffb22a2755b
   107 	*mikmod.md_reverb  = 0;
   107 	*mikmod.md_reverb  = 0;
   108 	*mikmod.md_mode    |= DMODE_HQMIXER|DMODE_SOFT_MUSIC|DMODE_SURROUND;
   108 	*mikmod.md_mode    |= DMODE_HQMIXER|DMODE_SOFT_MUSIC|DMODE_SURROUND;
   109 
   109 
   110 	list = mikmod.MikMod_InfoDriver();
   110 	list = mikmod.MikMod_InfoDriver();
   111 	if ( list )
   111 	if ( list )
   112 	  free(list);
   112 	  mikmod.MikMod_free(list);
   113 	else
   113 	else
   114 	  mikmod.MikMod_RegisterDriver(mikmod.drv_nos);
   114 	  mikmod.MikMod_RegisterDriver(mikmod.drv_nos);
   115 
   115 
   116 	list = mikmod.MikMod_InfoLoader();
   116 	list = mikmod.MikMod_InfoLoader();
   117 	if ( list )
   117 	if ( list )
   118 	  free(list);
   118 	  mikmod.MikMod_free(list);
   119 	else
   119 	else
   120 	  mikmod.MikMod_RegisterAllLoaders();
   120 	  mikmod.MikMod_RegisterAllLoaders();
   121 
   121 
   122 	if ( mikmod.MikMod_Init(NULL) ) {
   122 	if ( mikmod.MikMod_Init(NULL) ) {
   123 		Mix_SetError("%s", mikmod.MikMod_strerror(*mikmod.MikMod_errno));
   123 		Mix_SetError("%s", mikmod.MikMod_strerror(*mikmod.MikMod_errno));
   142 }
   142 }
   143 
   143 
   144 typedef struct
   144 typedef struct
   145 {
   145 {
   146 	MREADER mr;
   146 	MREADER mr;
       
   147 	/* struct MREADER in libmikmod <= 3.2.0-beta2
       
   148 	 * doesn't have iobase members. adding them here
       
   149 	 * so that if we compile against 3.2.0-beta2, we
       
   150 	 * can still run OK against 3.2.0b3 and newer. */
       
   151 	long iobase, prev_iobase;
   147 	long offset;
   152 	long offset;
   148 	long eof;
   153 	long eof;
   149 	SDL_RWops *rw;
   154 	SDL_RWops *rw;
   150 } LMM_MREADER;
   155 } LMM_MREADER;
   151 
   156 
   152 BOOL LMM_Seek(struct MREADER *mr,long to,int dir)
   157 int LMM_Seek(struct MREADER *mr,long to,int dir)
   153 {
   158 {
   154 	LMM_MREADER* lmmmr = (LMM_MREADER*)mr;
   159 	LMM_MREADER* lmmmr = (LMM_MREADER*)mr;
   155 	if ( dir == SEEK_SET ) {
   160 	if ( dir == SEEK_SET ) {
   156 		to += lmmmr->offset;
   161 		to += lmmmr->offset;
   157 	}
   162 		if (to < lmmmr->offset)
   158 	return (SDL_RWseek(lmmmr->rw, to, dir) < lmmmr->offset);
   163 			return -1;
       
   164 	}
       
   165 	return (SDL_RWseek(lmmmr->rw, to, dir) < lmmmr->offset)? -1 : 0;
   159 }
   166 }
   160 long LMM_Tell(struct MREADER *mr)
   167 long LMM_Tell(struct MREADER *mr)
   161 {
   168 {
   162 	LMM_MREADER* lmmmr = (LMM_MREADER*)mr;
   169 	LMM_MREADER* lmmmr = (LMM_MREADER*)mr;
   163 	return SDL_RWtell(lmmmr->rw) - lmmmr->offset;
   170 	return SDL_RWtell(lmmmr->rw) - lmmmr->offset;