Skip to content
Permalink
Browse files

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.
  • Loading branch information
slouken committed Jul 15, 2007
1 parent 5cd8b9b commit 26e2d35ec75e80c63de0251844181469529d6808
Showing with 8 additions and 30 deletions.
  1. +2 −0 CHANGES
  2. +6 −30 music_ogg.c
@@ -1,4 +1,6 @@
1.2.8:
Sam Lantinga - Sat Jul 14 21:05:09 PDT 2007
* Fixed opening Ogg Vorbis files using different C runtimes on Windows
Philippe Simons - Sat Jul 14 20:33:17 PDT 2007
* Added support for Ogg Vorbis playback with Tremor (an integer decoder)
Sam Lantinga - Sat Jul 14 07:02:09 PDT 2007
@@ -55,38 +55,14 @@ void OGG_setvolume(OGG_music *music, int volume)
/* Load an OGG stream from the given file */
OGG_music *OGG_new(const char *file)
{
OGG_music *music;
FILE *fp;

music = (OGG_music *)malloc(sizeof *music);
if ( music ) {
/* Initialize the music structure */
memset(music, 0, (sizeof *music));
OGG_stop(music);
OGG_setvolume(music, MIX_MAX_VOLUME);
music->section = -1;
SDL_RWops *rw;

if ( Mix_InitOgg() < 0 ) {
return(NULL);
}
fp = fopen(file, "rb");
if ( fp == NULL ) {
free(music);
Mix_QuitOgg();
SDL_SetError("Couldn't open %s", file);
return(NULL);
}
if ( vorbis.ov_open(fp, &music->vf, NULL, 0) < 0 ) {
fclose(fp);
free(music);
Mix_QuitOgg();
SDL_SetError("Not an Ogg Vorbis audio stream");
return(NULL);
}
} else {
SDL_OutOfMemory();
rw = SDL_RWFromFile(file, "rb");
if ( rw == NULL ) {
SDL_SetError("Couldn't open %s", file);
return NULL;
}
return(music);
return OGG_new_RW(rw);
}


0 comments on commit 26e2d35

Please sign in to comment.