changeset 226:57e16a6d244f

Fixed an incorrect assertion.
author Ryan C. Gordon <icculus@icculus.org>
date Sat, 19 Jan 2002 01:53:30 +0000
parents 3b4415a39466
children 7e74765ad928
files SDL_sound.c
diffstat 1 files changed, 22 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- 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)