# HG changeset patch # User Ryan C. Gordon # Date 1011405210 0 # Node ID 57e16a6d244f61f2531d452236b79718d35492b8 # Parent 3b4415a394667765b8580f83f9df615b09c89b10 Fixed an incorrect assertion. diff -r 3b4415a39466 -r 57e16a6d244f SDL_sound.c --- a/SDL_sound.c Sat Jan 19 01:53:15 2002 +0000 +++ b/SDL_sound.c Sat Jan 19 01:53:30 2002 +0000 @@ -200,13 +200,13 @@ samplesList = NULL; errorMessages = NULL; - SDL_Init(SDL_INIT_AUDIO); - errorlist_mutex = SDL_CreateMutex(); - available_decoders = (const Sound_DecoderInfo **) malloc((total) * sizeof (Sound_DecoderInfo *)); BAIL_IF_MACRO(available_decoders == NULL, ERR_OUT_OF_MEMORY, 0); + SDL_Init(SDL_INIT_AUDIO); + errorlist_mutex = SDL_CreateMutex(); + for (i = 0; decoders[i].funcs != NULL; i++) { decoders[i].available = decoders[i].funcs->init(); @@ -257,12 +257,12 @@ nexterr = err->next; free(err); } /* for */ + errorMessages = NULL; + initialized = 0; SDL_UnlockMutex(errorlist_mutex); SDL_DestroyMutex(errorlist_mutex); - errorMessages = NULL; errorlist_mutex = NULL; - initialized = 0; return(1); } /* Sound_Quit */ @@ -301,7 +301,12 @@ const char *Sound_GetError(void) { const char *retval = NULL; - ErrMsg *err = findErrorForCurrentThread(); + ErrMsg *err; + + if (!initialized) + return(ERR_NOT_INITIALIZED); + + err = findErrorForCurrentThread(); if ((err != NULL) && (err->errorAvailable)) { retval = err->errorString; @@ -314,7 +319,12 @@ void Sound_ClearError(void) { - ErrMsg *err = findErrorForCurrentThread(); + ErrMsg *err; + + if (!initialized) + return; + + err = findErrorForCurrentThread(); if (err != NULL) err->errorAvailable = 0; } /* Sound_ClearError */ @@ -330,7 +340,11 @@ if (str == NULL) return; - SNDDBG(("Sound_SetError(\"%s\");\n", str)); + SNDDBG(("Sound_SetError(\"%s\");%s\n", str, + (initialized) ? "" : " [NOT INITIALIZED!]")); + + if (!initialized) + return; err = findErrorForCurrentThread(); if (err == NULL)