Simple Directmedia Layer

Fixed infinite recursion when the microphone is unavailable

+12 -4
+12 -4
src/audio/coreaudio/SDL_coreaudio.m
··· 436 436 } 437 437 } 438 438 } else if (data.playback && data.recording) { 439 - category = AVAudioSessionCategoryPlayAndRecord; 439 + if (allow_playandrecord) { 440 + category = AVAudioSessionCategoryPlayAndRecord; 441 + } else { 442 + // We already failed play and record with AVAudioSessionErrorCodeResourceNotAvailable 443 + return false; 444 + } 440 445 } else if (data.recording) { 441 446 category = AVAudioSessionCategoryRecord; 442 447 } ··· 494 499 if (![session setActive:YES error:&err]) { 495 500 if ([err code] == AVAudioSessionErrorCodeResourceNotAvailable && 496 501 category == AVAudioSessionCategoryPlayAndRecord) { 497 - return UpdateAudioSession(device, open, false); 502 + if (UpdateAudioSession(device, open, false)) { 503 + return true; 504 + } else { 505 + return SDL_SetError("Could not activate Audio Session: Resource not available"); 506 + } 498 507 } 499 508 500 509 NSString *desc = err.description; 501 - SDL_SetError("Could not activate Audio Session: %s", desc.UTF8String); 502 - return false; 510 + return SDL_SetError("Could not activate Audio Session: %s", desc.UTF8String); 503 511 } 504 512 session_active = true; 505 513 ResumeAudioDevices();