Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
icculus committed Jan 26, 2010
1 parent e162db4 commit beefdea
Show file tree
Hide file tree
Showing 22 changed files with 26 additions and 50 deletions.
26 changes: 2 additions & 24 deletions src/audio/SDL_audio.c
Expand Up @@ -581,8 +581,6 @@ SDL_AudioInit(const char *driver_name)
int i = 0;
int initialized = 0;
int tried_to_init = 0;
int rc = 0;
int best_choice = -1;

if (SDL_WasInit(SDL_INIT_AUDIO)) {
SDL_AudioQuit(); /* shutdown driver if already running. */
Expand All @@ -608,34 +606,14 @@ SDL_AudioInit(const char *driver_name)
SDL_memset(&current_audio, 0, sizeof(current_audio));
current_audio.name = backend->name;
current_audio.desc = backend->desc;
rc = backend->init(&current_audio.impl);
if (rc == 2) { /* init'd, and devices available. Take it! */
initialized = 1;
best_choice = i;
} else if (rc == 1) { /* init'd, but can't see any devices. */
if (current_audio.impl.Deinitialize) {
current_audio.impl.Deinitialize();
}
if (best_choice == -1) {
best_choice = i;
}
}
}

/* No definite choice. Pick one that works but can't promise a device. */
if ((!initialized) && (best_choice != -1)) {
const AudioBootStrap *backend = bootstrap[best_choice];
SDL_memset(&current_audio, 0, sizeof(current_audio));
current_audio.name = backend->name;
current_audio.desc = backend->desc;
initialized = (backend->init(&current_audio.impl) > 0);
initialized = backend->init(&current_audio.impl);
}

if (!initialized) {
/* specific drivers will set the error message if they fail... */
if (!tried_to_init) {
if (driver_name) {
SDL_SetError("%s not available", driver_name);
SDL_SetError("Audio target '%s' not available", driver_name);
} else {
SDL_SetError("No available audio device");
}
Expand Down
2 changes: 1 addition & 1 deletion src/audio/alsa/SDL_alsa_audio.c
Expand Up @@ -681,7 +681,7 @@ ALSA_Init(SDL_AudioDriverImpl * impl)
impl->Deinitialize = ALSA_Deinitialize;
impl->OnlyHasDefaultOutputDevice = 1; /* !!! FIXME: Add device enum! */

return 1; /* !!! FIXME: return 2 once device enum is implemented. */
return 1; /* this audio target is available. */
}


Expand Down
2 changes: 1 addition & 1 deletion src/audio/arts/SDL_artsaudio.c
Expand Up @@ -368,7 +368,7 @@ ARTS_Init(SDL_AudioDriverImpl * impl)
impl->Deinitialize = ARTS_Deinitialize;
impl->OnlyHasDefaultOutputDevice = 1;

return 1;
return 1; /* this audio target is available. */
}


Expand Down
2 changes: 1 addition & 1 deletion src/audio/baudio/SDL_beaudio.cc
Expand Up @@ -204,7 +204,7 @@ BEOSAUDIO_Init(SDL_AudioDriverImpl * impl)
impl->ProvidesOwnCallbackThread = 1;
impl->OnlyHasDefaultOutputDevice = 1;

return 1;
return 1; /* this audio target is available. */
}

extern "C"
Expand Down
3 changes: 2 additions & 1 deletion src/audio/bsd/SDL_bsdaudio.c
Expand Up @@ -444,7 +444,8 @@ BSDAUDIO_Init(SDL_AudioDriverImpl * impl)
impl->Deinitialize = BSDAUDIO_Deinitialize;

build_device_lists();
return (outputDeviceCount > 0) ? 2 : 1;

return 1; /* this audio target is available. */
}


Expand Down
2 changes: 1 addition & 1 deletion src/audio/disk/SDL_diskaudio.c
Expand Up @@ -158,7 +158,7 @@ DISKAUD_Init(SDL_AudioDriverImpl * impl)
impl->GetDeviceBuf = DISKAUD_GetDeviceBuf;
impl->CloseDevice = DISKAUD_CloseDevice;

return 1;
return 1; /* this audio target is available. */
}

AudioBootStrap DISKAUD_bootstrap = {
Expand Down
3 changes: 2 additions & 1 deletion src/audio/dma/SDL_dmaaudio.c
Expand Up @@ -524,7 +524,8 @@ DMA_Init(SDL_AudioDriverImpl * impl)
impl->Deinitialize = DMA_Deinitialize;

build_device_lists();
return (outputDeviceCount > 0) ? 2 : 1;

return 1; /* this audio target is available. */
}

AudioBootStrap DMA_bootstrap = {
Expand Down
2 changes: 1 addition & 1 deletion src/audio/dmedia/SDL_irixaudio.c
Expand Up @@ -228,7 +228,7 @@ IRIXAUDIO_Init(SDL_AudioDriverImpl * impl)
impl->CloseDevice = DSP_CloseDevice;
impl->OnlyHasDefaultOutputDevice = 1; /* !!! FIXME: not true, I think. */

return 1;
return 1; /* this audio target is available. */
}

AudioBootStrap IRIXAUDIO_bootstrap = {
Expand Down
3 changes: 2 additions & 1 deletion src/audio/dsp/SDL_dspaudio.c
Expand Up @@ -381,7 +381,8 @@ DSP_Init(SDL_AudioDriverImpl * impl)
impl->Deinitialize = DSP_Deinitialize;

build_device_lists();
return (outputDeviceCount > 0) ? 2 : 1;

return 1; /* this audio target is available. */
}


Expand Down
2 changes: 1 addition & 1 deletion src/audio/dummy/SDL_dummyaudio.c
Expand Up @@ -41,7 +41,7 @@ DUMMYAUD_Init(SDL_AudioDriverImpl * impl)
/* Set the function pointers */
impl->OpenDevice = DUMMYAUD_OpenDevice;
impl->OnlyHasDefaultOutputDevice = 1;
return 1;
return 1; /* this audio target is available. */
}

AudioBootStrap DUMMYAUD_bootstrap = {
Expand Down
2 changes: 1 addition & 1 deletion src/audio/esd/SDL_esdaudio.c
Expand Up @@ -341,7 +341,7 @@ ESD_Init(SDL_AudioDriverImpl * impl)
impl->Deinitialize = ESD_Deinitialize;
impl->OnlyHasDefaultOutputDevice = 1;

return 2; /* return 2 (definitely have a "device"). */
return 1; /* this audio target is available. */
}


Expand Down
2 changes: 1 addition & 1 deletion src/audio/fusionsound/SDL_fsaudio.c
Expand Up @@ -340,7 +340,7 @@ SDL_FS_Init(SDL_AudioDriverImpl * impl)
impl->Deinitialize = SDL_FS_Deinitialize;
impl->OnlyHasDefaultOutputDevice = 1;

return 1;
return 1; /* this audio target is available. */
}


Expand Down
2 changes: 1 addition & 1 deletion src/audio/iphoneos/SDL_coreaudio_iphone.c
Expand Up @@ -329,7 +329,7 @@ COREAUDIO_Init(SDL_AudioDriverImpl * impl)
impl->OnlyHasDefaultOutputDevice = 1;
impl->HasCaptureSupport = 0; /* still needs to be written */

return 2; /* defitely have an audio device. */
return 1; /* this audio target is available. */
}

AudioBootStrap COREAUDIOIPHONE_bootstrap = {
Expand Down
2 changes: 1 addition & 1 deletion src/audio/macosx/SDL_coreaudio.c
Expand Up @@ -574,7 +574,7 @@ COREAUDIO_Init(SDL_AudioDriverImpl * impl)

build_device_lists(); /* do an initial check for devices... */

return (outputDeviceCount > 0) ? 2 : 1;
return 1; /* this audio target is available. */
}

AudioBootStrap COREAUDIO_bootstrap = {
Expand Down
2 changes: 1 addition & 1 deletion src/audio/mme/SDL_mmeaudio.c
Expand Up @@ -249,7 +249,7 @@ MME_Init(SDL_AudioDriverImpl * impl)
impl->CloseDevice = MME_CloseDevice;
impl->OnlyHasDefaultOutputDevice = 1;

return 1;
return 1; /* this audio target is available. */
}

/* !!! FIXME: Windows "windib" driver is called waveout, too */
Expand Down
2 changes: 1 addition & 1 deletion src/audio/nas/SDL_nasaudio.c
Expand Up @@ -398,7 +398,7 @@ NAS_Init(SDL_AudioDriverImpl * impl)
impl->Deinitialize = NAS_Deinitialize;
impl->OnlyHasDefaultOutputDevice = 1; /* !!! FIXME: is this true? */

return 2; /* 2 == definitely has an audio device. */
return 1; /* this audio target is available. */
}

AudioBootStrap NAS_bootstrap = {
Expand Down
2 changes: 1 addition & 1 deletion src/audio/nds/SDL_ndsaudio.c
Expand Up @@ -120,7 +120,7 @@ NDSAUD_Init(SDL_AudioDriverImpl * impl)
impl->OnlyHasDefaultOutputDevice = 1;
impl->OnlyHasDefaultInputDevice = 1;

return 2; /* 2 == definitely has an audio device. */
return 1; /* this audio target is available. */
}

AudioBootStrap NDSAUD_bootstrap = {
Expand Down
3 changes: 1 addition & 2 deletions src/audio/paudio/SDL_paudio.c
Expand Up @@ -544,8 +544,7 @@ PAUDIO_Init(SDL_AudioDriverImpl * impl)
impl->CloseDevice = DSP_CloseDevice;
impl->OnlyHasDefaultOutputDevice = 1; /* !!! FIXME: add device enum! */

/* !!! FIXME: device enum might make this 1. */
return 2; /* 2 == definitely has an audio device. */
return 1; /* this audio target is available. */
}

AudioBootStrap PAUDIO_bootstrap = {
Expand Down
3 changes: 1 addition & 2 deletions src/audio/pulseaudio/SDL_pulseaudio.c
Expand Up @@ -529,8 +529,7 @@ PULSEAUDIO_Init(SDL_AudioDriverImpl * impl)
impl->Deinitialize = PULSEAUDIO_Deinitialize;
impl->OnlyHasDefaultOutputDevice = 1;

/* !!! FIXME: should test if server is available here, return 2 if so. */
return 1;
return 1; /* this audio target is available. */
}


Expand Down
3 changes: 1 addition & 2 deletions src/audio/qsa/SDL_qsa_audio.c
Expand Up @@ -883,8 +883,7 @@ QSA_Init(SDL_AudioDriverImpl * impl)
return 1;
}

/* At this point we are definitely has an audio device */
return 2;
return 1; /* this audio target is available. */
}

AudioBootStrap QSAAUDIO_bootstrap = {
Expand Down
3 changes: 1 addition & 2 deletions src/audio/windib/SDL_dibaudio.c
Expand Up @@ -327,8 +327,7 @@ WINWAVEOUT_Init(SDL_AudioDriverImpl * impl)
impl->CloseDevice = WINWAVEOUT_CloseDevice;
impl->OnlyHasDefaultOutputDevice = 1; /* !!! FIXME: Is this true? */

/* !!! FIXME: not right for device enum? */
return 1;
return 1; /* this audio target is available. */
}

AudioBootStrap WINWAVEOUT_bootstrap = {
Expand Down
3 changes: 1 addition & 2 deletions src/audio/windx5/SDL_dx5audio.c
Expand Up @@ -508,8 +508,7 @@ DSOUND_Init(SDL_AudioDriverImpl * impl)
impl->Deinitialize = DSOUND_Deinitialize;
impl->OnlyHasDefaultOutputDevice = 1; /* !!! FIXME */

/* !!! FIXME: not right for device enum? */
return 1;
return 1; /* this audio target is available. */
}

AudioBootStrap DSOUND_bootstrap = {
Expand Down

0 comments on commit beefdea

Please sign in to comment.