mirror of
https://github.com/Relintai/sdl2_frt.git
synced 2025-02-22 07:37:56 +01:00
Fixed audio not coming out of the phone speakers while recording on iOS
This commit is contained in:
parent
922b3dc3e7
commit
f4e23553d7
@ -326,12 +326,18 @@ static BOOL update_audio_session(_THIS, SDL_bool open)
|
|||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
AVAudioSession *session = [AVAudioSession sharedInstance];
|
AVAudioSession *session = [AVAudioSession sharedInstance];
|
||||||
NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
|
NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
|
||||||
|
|
||||||
/* Set category to ambient by default so that other music continues playing. */
|
/* Set category to ambient by default so that other music continues playing. */
|
||||||
NSString *category = AVAudioSessionCategoryAmbient;
|
NSString *category = AVAudioSessionCategoryAmbient;
|
||||||
|
NSString *mode = AVAudioSessionModeDefault;
|
||||||
|
NSUInteger options = 0;
|
||||||
NSError *err = nil;
|
NSError *err = nil;
|
||||||
|
|
||||||
if (open_playback_devices && open_capture_devices) {
|
if (open_playback_devices && open_capture_devices) {
|
||||||
category = AVAudioSessionCategoryPlayAndRecord;
|
category = AVAudioSessionCategoryPlayAndRecord;
|
||||||
|
#if !TARGET_OS_TV
|
||||||
|
options = AVAudioSessionCategoryOptionDefaultToSpeaker;
|
||||||
|
#endif
|
||||||
} else if (open_capture_devices) {
|
} else if (open_capture_devices) {
|
||||||
category = AVAudioSessionCategoryRecord;
|
category = AVAudioSessionCategoryRecord;
|
||||||
} else {
|
} else {
|
||||||
@ -348,11 +354,19 @@ static BOOL update_audio_session(_THIS, SDL_bool open)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ([session respondsToSelector:@selector(setCategory:mode:options:error:)]) {
|
||||||
|
if (![session setCategory:category mode:mode options:options error:&err]) {
|
||||||
|
NSString *desc = err.description;
|
||||||
|
SDL_SetError("Could not set Audio Session category: %s", desc.UTF8String);
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
if (![session setCategory:category error:&err]) {
|
if (![session setCategory:category error:&err]) {
|
||||||
NSString *desc = err.description;
|
NSString *desc = err.description;
|
||||||
SDL_SetError("Could not set Audio Session category: %s", desc.UTF8String);
|
SDL_SetError("Could not set Audio Session category: %s", desc.UTF8String);
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (open && (open_playback_devices + open_capture_devices) == 1) {
|
if (open && (open_playback_devices + open_capture_devices) == 1) {
|
||||||
if (![session setActive:YES error:&err]) {
|
if (![session setActive:YES error:&err]) {
|
||||||
|
Loading…
Reference in New Issue
Block a user