music_modplug.c
changeset 561 87bdb4c81c0b
parent 542 3de4970b36d4
child 617 87116a42526e
equal deleted inserted replaced
560:0fc8dffb86c5 561:87bdb4c81c0b
    83 
    83 
    84 	offset = SDL_RWtell(rw);
    84 	offset = SDL_RWtell(rw);
    85 	SDL_RWseek(rw, 0, RW_SEEK_END);
    85 	SDL_RWseek(rw, 0, RW_SEEK_END);
    86 	sz = SDL_RWtell(rw)-offset;
    86 	sz = SDL_RWtell(rw)-offset;
    87 	SDL_RWseek(rw, offset, RW_SEEK_SET);
    87 	SDL_RWseek(rw, offset, RW_SEEK_SET);
    88 	buf=(char*)malloc(sz);
    88 	buf=(char*)SDL_malloc(sz);
    89 	if(buf)
    89 	if(buf)
    90 	{
    90 	{
    91 		if(SDL_RWread(rw, buf, sz, 1)==1)
    91 		if(SDL_RWread(rw, buf, sz, 1)==1)
    92 		{
    92 		{
    93 			music=(modplug_data*)malloc(sizeof(modplug_data));
    93 			music=(modplug_data*)SDL_malloc(sizeof(modplug_data));
    94 			if (music)
    94 			if (music)
    95 			{
    95 			{
    96 				music->playing=0;
    96 				music->playing=0;
    97 				music->file=ModPlug_Load(buf,sz);
    97 				music->file=ModPlug_Load(buf,sz);
    98 				if(!music->file)
    98 				if(!music->file)
    99 				{
    99 				{
   100 					free(music);
   100 					SDL_free(music);
   101 					music=NULL;
   101 					music=NULL;
   102 				}
   102 				}
   103 			}
   103 			}
   104 			else
   104 			else
   105 			{
   105 			{
   106 				SDL_OutOfMemory();
   106 				SDL_OutOfMemory();
   107 			}
   107 			}
   108 		}
   108 		}
   109 		free(buf);
   109 		SDL_free(buf);
   110 	}
   110 	}
   111 	else
   111 	else
   112 	{
   112 	{
   113 		SDL_OutOfMemory();
   113 		SDL_OutOfMemory();
   114 	}
   114 	}
   225 
   225 
   226 /* Close the given modplug stream */
   226 /* Close the given modplug stream */
   227 void modplug_delete(modplug_data *music)
   227 void modplug_delete(modplug_data *music)
   228 {
   228 {
   229 	ModPlug_Unload(music->file);
   229 	ModPlug_Unload(music->file);
   230 	free(music);
   230 	SDL_free(music);
   231 }
   231 }
   232 
   232 
   233 /* Jump (seek) to a given position (time is in seconds) */
   233 /* Jump (seek) to a given position (time is in seconds) */
   234 void modplug_jump_to_time(modplug_data *music, double time)
   234 void modplug_jump_to_time(modplug_data *music, double time)
   235 {
   235 {