audio: Fixed logic error

main
Ryan C. Gordon 2023-07-04 17:27:09 -04:00
parent 4deb2970c9
commit f94ffd6092
No known key found for this signature in database
GPG Key ID: FA148B892AB48044
1 changed files with 3 additions and 3 deletions

View File

@ -475,7 +475,7 @@ static SDL_AudioDeviceID GetFirstAddedAudioDeviceID(const SDL_bool iscapture)
// (these are pushed to the front of the linked list as added, so the first device added is last in the list.) // (these are pushed to the front of the linked list as added, so the first device added is last in the list.)
SDL_LockRWLockForReading(current_audio.device_list_lock); SDL_LockRWLockForReading(current_audio.device_list_lock);
SDL_AudioDevice *last = NULL; SDL_AudioDevice *last = NULL;
for (SDL_AudioDevice *i = current_audio.output_devices; i != NULL; i = i->next) { for (SDL_AudioDevice *i = iscapture ? current_audio.capture_devices : current_audio.output_devices; i != NULL; i = i->next) {
last = i; last = i;
} }
const SDL_AudioDeviceID retval = last ? last->instance_id : 0; const SDL_AudioDeviceID retval = last ? last->instance_id : 0;
@ -599,8 +599,8 @@ int SDL_InitAudio(const char *driver_name)
if (!current_audio.default_output_device_id) { if (!current_audio.default_output_device_id) {
current_audio.default_output_device_id = GetFirstAddedAudioDeviceID(/*iscapture=*/SDL_FALSE); current_audio.default_output_device_id = GetFirstAddedAudioDeviceID(/*iscapture=*/SDL_FALSE);
} }
if (!current_audio.default_capture_device_id && (current_audio.capture_devices != NULL)) { if (!current_audio.default_capture_device_id) {
current_audio.default_output_device_id = GetFirstAddedAudioDeviceID(/*iscapture=*/SDL_TRUE); current_audio.default_capture_device_id = GetFirstAddedAudioDeviceID(/*iscapture=*/SDL_TRUE);
} }
return 0; return 0;