music_ogg.c
changeset 625 1d489d8ec2e0
parent 621 944412baab72
child 642 dae7bb0a66b1
     1.1 --- a/music_ogg.c	Sat Jun 01 15:49:18 2013 -0700
     1.2 +++ b/music_ogg.c	Sat Jun 01 19:52:15 2013 -0700
     1.3 @@ -67,15 +67,12 @@
     1.4  }
     1.5  
     1.6  /* Load an OGG stream from an SDL_RWops object */
     1.7 -OGG_music *OGG_new_RW(SDL_RWops *rw, int freerw)
     1.8 +OGG_music *OGG_new_RW(SDL_RWops *src, int freesrc)
     1.9  {
    1.10      OGG_music *music;
    1.11      ov_callbacks callbacks;
    1.12  
    1.13      if ( !Mix_Init(MIX_INIT_OGG) ) {
    1.14 -        if ( freerw ) {
    1.15 -            SDL_RWclose(rw);
    1.16 -        }
    1.17          return(NULL);
    1.18      }
    1.19  
    1.20 @@ -88,24 +85,18 @@
    1.21      if ( music ) {
    1.22          /* Initialize the music structure */
    1.23          SDL_memset(music, 0, (sizeof *music));
    1.24 -        music->rw = rw;
    1.25 -        music->freerw = freerw;
    1.26 +        music->src = src;
    1.27 +        music->freesrc = freesrc;
    1.28          OGG_stop(music);
    1.29          OGG_setvolume(music, MIX_MAX_VOLUME);
    1.30          music->section = -1;
    1.31  
    1.32 -        if ( vorbis.ov_open_callbacks(rw, &music->vf, NULL, 0, callbacks) < 0 ) {
    1.33 +        if ( vorbis.ov_open_callbacks(src, &music->vf, NULL, 0, callbacks) < 0 ) {
    1.34 +            SDL_SetError("Not an Ogg Vorbis audio stream");
    1.35              SDL_free(music);
    1.36 -            if ( freerw ) {
    1.37 -                SDL_RWclose(rw);
    1.38 -            }
    1.39 -            SDL_SetError("Not an Ogg Vorbis audio stream");
    1.40              return(NULL);
    1.41          }
    1.42      } else {
    1.43 -        if ( freerw ) {
    1.44 -            SDL_RWclose(rw);
    1.45 -        }
    1.46          SDL_OutOfMemory();
    1.47          return(NULL);
    1.48      }
    1.49 @@ -213,8 +204,8 @@
    1.50          if ( music->cvt.buf ) {
    1.51              SDL_free(music->cvt.buf);
    1.52          }
    1.53 -        if ( music->freerw ) {
    1.54 -            SDL_RWclose(music->rw);
    1.55 +        if ( music->freesrc ) {
    1.56 +            SDL_RWclose(music->src);
    1.57          }
    1.58          vorbis.ov_clear(&music->vf);
    1.59          SDL_free(music);