comparison src/audio/SDL_audio.c @ 3699:4160ba33b597

Removed test for "driver is valid, but doesn't see any audio devices." It was causing problems, and it really doesn't make sense to do it that way. Fixes Bugzilla #834.
author Ryan C. Gordon <icculus@icculus.org>
date Tue, 26 Jan 2010 06:01:33 +0000
parents f7b03b6838cb
children 791b3256fb22 79aa6c61f33b
comparison
equal deleted inserted replaced
3698:17376128fb56 3699:4160ba33b597
579 SDL_AudioInit(const char *driver_name) 579 SDL_AudioInit(const char *driver_name)
580 { 580 {
581 int i = 0; 581 int i = 0;
582 int initialized = 0; 582 int initialized = 0;
583 int tried_to_init = 0; 583 int tried_to_init = 0;
584 int rc = 0;
585 int best_choice = -1;
586 584
587 if (SDL_WasInit(SDL_INIT_AUDIO)) { 585 if (SDL_WasInit(SDL_INIT_AUDIO)) {
588 SDL_AudioQuit(); /* shutdown driver if already running. */ 586 SDL_AudioQuit(); /* shutdown driver if already running. */
589 } 587 }
590 588
606 604
607 tried_to_init = 1; 605 tried_to_init = 1;
608 SDL_memset(&current_audio, 0, sizeof(current_audio)); 606 SDL_memset(&current_audio, 0, sizeof(current_audio));
609 current_audio.name = backend->name; 607 current_audio.name = backend->name;
610 current_audio.desc = backend->desc; 608 current_audio.desc = backend->desc;
611 rc = backend->init(&current_audio.impl); 609 initialized = backend->init(&current_audio.impl);
612 if (rc == 2) { /* init'd, and devices available. Take it! */
613 initialized = 1;
614 best_choice = i;
615 } else if (rc == 1) { /* init'd, but can't see any devices. */
616 if (current_audio.impl.Deinitialize) {
617 current_audio.impl.Deinitialize();
618 }
619 if (best_choice == -1) {
620 best_choice = i;
621 }
622 }
623 }
624
625 /* No definite choice. Pick one that works but can't promise a device. */
626 if ((!initialized) && (best_choice != -1)) {
627 const AudioBootStrap *backend = bootstrap[best_choice];
628 SDL_memset(&current_audio, 0, sizeof(current_audio));
629 current_audio.name = backend->name;
630 current_audio.desc = backend->desc;
631 initialized = (backend->init(&current_audio.impl) > 0);
632 } 610 }
633 611
634 if (!initialized) { 612 if (!initialized) {
635 /* specific drivers will set the error message if they fail... */ 613 /* specific drivers will set the error message if they fail... */
636 if (!tried_to_init) { 614 if (!tried_to_init) {
637 if (driver_name) { 615 if (driver_name) {
638 SDL_SetError("%s not available", driver_name); 616 SDL_SetError("Audio target '%s' not available", driver_name);
639 } else { 617 } else {
640 SDL_SetError("No available audio device"); 618 SDL_SetError("No available audio device");
641 } 619 }
642 } 620 }
643 621