comparison SDL_sound.c @ 226:57e16a6d244f

Fixed an incorrect assertion.
author Ryan C. Gordon <icculus@icculus.org>
date Sat, 19 Jan 2002 01:53:30 +0000
parents 249186e31431
children ceadd952319a
comparison
equal deleted inserted replaced
225:3b4415a39466 226:57e16a6d244f
198 BAIL_IF_MACRO(initialized, ERR_IS_INITIALIZED, 0); 198 BAIL_IF_MACRO(initialized, ERR_IS_INITIALIZED, 0);
199 199
200 samplesList = NULL; 200 samplesList = NULL;
201 errorMessages = NULL; 201 errorMessages = NULL;
202 202
203 SDL_Init(SDL_INIT_AUDIO);
204 errorlist_mutex = SDL_CreateMutex();
205
206 available_decoders = (const Sound_DecoderInfo **) 203 available_decoders = (const Sound_DecoderInfo **)
207 malloc((total) * sizeof (Sound_DecoderInfo *)); 204 malloc((total) * sizeof (Sound_DecoderInfo *));
208 BAIL_IF_MACRO(available_decoders == NULL, ERR_OUT_OF_MEMORY, 0); 205 BAIL_IF_MACRO(available_decoders == NULL, ERR_OUT_OF_MEMORY, 0);
206
207 SDL_Init(SDL_INIT_AUDIO);
208 errorlist_mutex = SDL_CreateMutex();
209 209
210 for (i = 0; decoders[i].funcs != NULL; i++) 210 for (i = 0; decoders[i].funcs != NULL; i++)
211 { 211 {
212 decoders[i].available = decoders[i].funcs->init(); 212 decoders[i].available = decoders[i].funcs->init();
213 if (decoders[i].available) 213 if (decoders[i].available)
255 for (err = errorMessages; err != NULL; err = nexterr) 255 for (err = errorMessages; err != NULL; err = nexterr)
256 { 256 {
257 nexterr = err->next; 257 nexterr = err->next;
258 free(err); 258 free(err);
259 } /* for */ 259 } /* for */
260 errorMessages = NULL;
261 initialized = 0;
260 SDL_UnlockMutex(errorlist_mutex); 262 SDL_UnlockMutex(errorlist_mutex);
261 SDL_DestroyMutex(errorlist_mutex); 263 SDL_DestroyMutex(errorlist_mutex);
262 errorMessages = NULL;
263 errorlist_mutex = NULL; 264 errorlist_mutex = NULL;
264 265
265 initialized = 0;
266 return(1); 266 return(1);
267 } /* Sound_Quit */ 267 } /* Sound_Quit */
268 268
269 269
270 const Sound_DecoderInfo **Sound_AvailableDecoders(void) 270 const Sound_DecoderInfo **Sound_AvailableDecoders(void)
299 299
300 300
301 const char *Sound_GetError(void) 301 const char *Sound_GetError(void)
302 { 302 {
303 const char *retval = NULL; 303 const char *retval = NULL;
304 ErrMsg *err = findErrorForCurrentThread(); 304 ErrMsg *err;
305
306 if (!initialized)
307 return(ERR_NOT_INITIALIZED);
308
309 err = findErrorForCurrentThread();
305 if ((err != NULL) && (err->errorAvailable)) 310 if ((err != NULL) && (err->errorAvailable))
306 { 311 {
307 retval = err->errorString; 312 retval = err->errorString;
308 err->errorAvailable = 0; 313 err->errorAvailable = 0;
309 } /* if */ 314 } /* if */
312 } /* Sound_GetError */ 317 } /* Sound_GetError */
313 318
314 319
315 void Sound_ClearError(void) 320 void Sound_ClearError(void)
316 { 321 {
317 ErrMsg *err = findErrorForCurrentThread(); 322 ErrMsg *err;
323
324 if (!initialized)
325 return;
326
327 err = findErrorForCurrentThread();
318 if (err != NULL) 328 if (err != NULL)
319 err->errorAvailable = 0; 329 err->errorAvailable = 0;
320 } /* Sound_ClearError */ 330 } /* Sound_ClearError */
321 331
322 332
328 ErrMsg *err; 338 ErrMsg *err;
329 339
330 if (str == NULL) 340 if (str == NULL)
331 return; 341 return;
332 342
333 SNDDBG(("Sound_SetError(\"%s\");\n", str)); 343 SNDDBG(("Sound_SetError(\"%s\");%s\n", str,
344 (initialized) ? "" : " [NOT INITIALIZED!]"));
345
346 if (!initialized)
347 return;
334 348
335 err = findErrorForCurrentThread(); 349 err = findErrorForCurrentThread();
336 if (err == NULL) 350 if (err == NULL)
337 { 351 {
338 err = (ErrMsg *) malloc(sizeof (ErrMsg)); 352 err = (ErrMsg *) malloc(sizeof (ErrMsg));