fluidsynth.c
changeset 625 1d489d8ec2e0
parent 621 944412baab72
child 705 fe757163b8f7
     1.1 --- a/fluidsynth.c	Sat Jun 01 15:49:18 2013 -0700
     1.2 +++ b/fluidsynth.c	Sat Jun 01 19:52:15 2013 -0700
     1.3 @@ -111,18 +111,18 @@
     1.4  
     1.5  static int fluidsynth_loadsong_RW_internal(FluidSynthMidiSong *song, void *data)
     1.6  {
     1.7 -    off_t offset;
     1.8 +    Sint64 offset;
     1.9      size_t size;
    1.10      char *buffer;
    1.11 -    SDL_RWops *rw = (SDL_RWops*) data;
    1.12 +    SDL_RWops *src = (SDL_RWops*) data;
    1.13  
    1.14 -    offset = SDL_RWtell(rw);
    1.15 -    SDL_RWseek(rw, 0, RW_SEEK_END);
    1.16 -    size = SDL_RWtell(rw) - offset;
    1.17 -    SDL_RWseek(rw, offset, RW_SEEK_SET);
    1.18 +    offset = SDL_RWtell(src);
    1.19 +    SDL_RWseek(src, 0, RW_SEEK_END);
    1.20 +    size = (size_t)(SDL_RWtell(src) - offset);
    1.21 +    SDL_RWseek(src, offset, RW_SEEK_SET);
    1.22  
    1.23      if ((buffer = (char*) SDL_malloc(size))) {
    1.24 -        if(SDL_RWread(rw, buffer, size, 1) == 1) {
    1.25 +        if(SDL_RWread(src, buffer, size, 1) == 1) {
    1.26              if (fluidsynth.fluid_player_add_mem(song->player, buffer, size) == FLUID_OK) {
    1.27                  return 1;
    1.28              } else {
    1.29 @@ -138,13 +138,13 @@
    1.30      return 0;
    1.31  }
    1.32  
    1.33 -FluidSynthMidiSong *fluidsynth_loadsong_RW(SDL_RWops *rw, int freerw)
    1.34 +FluidSynthMidiSong *fluidsynth_loadsong_RW(SDL_RWops *src, int freesrc)
    1.35  {
    1.36      FluidSynthMidiSong *song;
    1.37  
    1.38 -    song = fluidsynth_loadsong_common(fluidsynth_loadsong_RW_internal, (void*) rw);
    1.39 -    if (freerw) {
    1.40 -        SDL_RWclose(rw);
    1.41 +    song = fluidsynth_loadsong_common(fluidsynth_loadsong_RW_internal, (void*) src);
    1.42 +    if (song && freesrc) {
    1.43 +        SDL_RWclose(src);
    1.44      }
    1.45      return song;
    1.46  }