Mercurial > SDL_sound_CoreAudio
comparison SDL_sound.c @ 149:1df5c106504e
Decoders can now list multiple file extensions.
author | Ryan C. Gordon <icculus@icculus.org> |
---|---|
date | Thu, 01 Nov 2001 19:13:17 +0000 |
parents | 3e60862fbd76 |
children | fa3e593b6a5e |
comparison
equal
deleted
inserted
replaced
148:d51546293fd1 | 149:1df5c106504e |
---|---|
442 | 442 |
443 | 443 |
444 Sound_Sample *Sound_NewSample(SDL_RWops *rw, const char *ext, | 444 Sound_Sample *Sound_NewSample(SDL_RWops *rw, const char *ext, |
445 Sound_AudioInfo *desired, Uint32 bSize) | 445 Sound_AudioInfo *desired, Uint32 bSize) |
446 { | 446 { |
447 size_t i; | |
448 Sound_Sample *retval; | 447 Sound_Sample *retval; |
448 decoder_element *decoder; | |
449 | 449 |
450 /* sanity checks. */ | 450 /* sanity checks. */ |
451 BAIL_IF_MACRO(!initialized, ERR_NOT_INITIALIZED, NULL); | 451 BAIL_IF_MACRO(!initialized, ERR_NOT_INITIALIZED, NULL); |
452 BAIL_IF_MACRO(rw == NULL, ERR_INVALID_ARGUMENT, NULL); | 452 BAIL_IF_MACRO(rw == NULL, ERR_INVALID_ARGUMENT, NULL); |
453 | 453 |
455 if (!retval) | 455 if (!retval) |
456 return(NULL); /* alloc_sample() sets error message... */ | 456 return(NULL); /* alloc_sample() sets error message... */ |
457 | 457 |
458 if (ext != NULL) | 458 if (ext != NULL) |
459 { | 459 { |
460 for (i = 0; decoders[i].funcs != NULL; i++) | 460 for (decoder = &decoders[0]; decoder->funcs != NULL; decoder++) |
461 { | 461 { |
462 if (decoders[i].available) | 462 if (decoder->available) |
463 { | 463 { |
464 const char *decoderExt = decoders[i].funcs->info.extension; | 464 const char **decoderExt = decoder->funcs->info.extensions; |
465 if (__Sound_strcasecmp(decoderExt, ext) == 0) | 465 while (*decoderExt) |
466 { | 466 { |
467 if (init_sample(decoders[i].funcs, retval, ext, desired)) | 467 if (__Sound_strcasecmp(*decoderExt, ext) == 0) |
468 return(retval); | 468 { |
469 } /* if */ | 469 if (init_sample(decoder->funcs, retval, ext, desired)) |
470 return(retval); | |
471 } /* if */ | |
472 decoderExt++; | |
473 } /* while */ | |
470 } /* if */ | 474 } /* if */ |
471 } /* for */ | 475 } /* for */ |
472 } /* if */ | 476 } /* if */ |
473 | 477 |
474 /* no direct extension match? Try everything we've got... */ | 478 /* no direct extension match? Try everything we've got... */ |
475 for (i = 0; decoders[i].funcs != NULL; i++) | 479 for (decoder = &decoders[0]; decoder->funcs != NULL; decoder++) |
476 { | 480 { |
477 if (decoders[i].available) | 481 if (decoder->available) |
478 { | 482 { |
479 if (init_sample(decoders[i].funcs, retval, ext, desired)) | 483 if (init_sample(decoder->funcs, retval, ext, desired)) |
480 return(retval); | 484 return(retval); |
481 } /* if */ | 485 } /* if */ |
482 } /* for */ | 486 } /* for */ |
483 | 487 |
484 /* nothing could handle the sound data... */ | 488 /* nothing could handle the sound data... */ |