Fixed bug #385
authorSam Lantinga <slouken@libsdl.org>
Sun, 15 Jul 2007 04:08:44 +0000
changeset 354e97cfc344dc3
parent 353 21fe62f9c4c6
child 355 f11a51438868
Fixed bug #385

Removed C runtime dependency for file I/O - fixes opening Ogg Vorbis files
on Windows with different versions of the C runtime.
CHANGES
music_ogg.c
     1.1 --- a/CHANGES	Sun Jul 15 03:38:33 2007 +0000
     1.2 +++ b/CHANGES	Sun Jul 15 04:08:44 2007 +0000
     1.3 @@ -1,4 +1,6 @@
     1.4  1.2.8:
     1.5 +Sam Lantinga - Sat Jul 14 21:05:09 PDT 2007
     1.6 + * Fixed opening Ogg Vorbis files using different C runtimes on Windows
     1.7  Philippe Simons - Sat Jul 14 20:33:17 PDT 2007
     1.8   * Added support for Ogg Vorbis playback with Tremor (an integer decoder)
     1.9  Sam Lantinga - Sat Jul 14 07:02:09 PDT 2007
     2.1 --- a/music_ogg.c	Sun Jul 15 03:38:33 2007 +0000
     2.2 +++ b/music_ogg.c	Sun Jul 15 04:08:44 2007 +0000
     2.3 @@ -55,38 +55,14 @@
     2.4  /* Load an OGG stream from the given file */
     2.5  OGG_music *OGG_new(const char *file)
     2.6  {
     2.7 -	OGG_music *music;
     2.8 -	FILE *fp;
     2.9 +	SDL_RWops *rw;
    2.10  
    2.11 -	music = (OGG_music *)malloc(sizeof *music);
    2.12 -	if ( music ) {
    2.13 -		/* Initialize the music structure */
    2.14 -		memset(music, 0, (sizeof *music));
    2.15 -		OGG_stop(music);
    2.16 -		OGG_setvolume(music, MIX_MAX_VOLUME);
    2.17 -		music->section = -1;
    2.18 -
    2.19 -		if ( Mix_InitOgg() < 0 ) {
    2.20 -			return(NULL);
    2.21 -		}
    2.22 -		fp = fopen(file, "rb");
    2.23 -		if ( fp == NULL ) {
    2.24 -			free(music);
    2.25 -			Mix_QuitOgg();
    2.26 -			SDL_SetError("Couldn't open %s", file);
    2.27 -			return(NULL);
    2.28 -		}
    2.29 -		if ( vorbis.ov_open(fp, &music->vf, NULL, 0) < 0 ) {
    2.30 -			fclose(fp);
    2.31 -			free(music);
    2.32 -			Mix_QuitOgg();
    2.33 -			SDL_SetError("Not an Ogg Vorbis audio stream");
    2.34 -			return(NULL);
    2.35 -		}
    2.36 -	} else {
    2.37 -		SDL_OutOfMemory();
    2.38 +	rw = SDL_RWFromFile(file, "rb");
    2.39 +	if ( rw == NULL ) {
    2.40 +		SDL_SetError("Couldn't open %s", file);
    2.41 +		return NULL;
    2.42  	}
    2.43 -	return(music);
    2.44 +	return OGG_new_RW(rw);
    2.45  }
    2.46  
    2.47