Skip to content

Commit

Permalink
Fixed bug #385
Browse files Browse the repository at this point in the history
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 26e2d35
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 30 deletions.
2 changes: 2 additions & 0 deletions CHANGES
@@ -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
Expand Down
36 changes: 6 additions & 30 deletions music_ogg.c
Expand Up @@ -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);
}


Expand Down

0 comments on commit 26e2d35

Please sign in to comment.