Compare commits

...
This repository has been archived on 2025-03-22. You can view files and clone it, but cannot push or open issues or pull requests.

1 commit

Author SHA1 Message Date
Fabian Wüthrich
3b9375b262
[ios] Configure audio session once with AVAudioSessionModeVoicePrompt
The audio session is once configured during initialisation and then each time a
audio session is set active. This commit configures the audio session only once
when the app is started. In addition, it sets AVAudioSessionModeVoicePrompt,
which is recommended for apps that use text-to-speech.

Signed-off-by: Fabian Wüthrich <me@fabwu.ch>
2024-08-17 12:52:48 -05:00

View file

@ -101,10 +101,11 @@ using Observers = NSHashTable<Observer>;
NSError * err = nil;
if (![[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback
withOptions:AVAudioSessionCategoryOptionMixWithOthers |
AVAudioSessionCategoryOptionDuckOthers
mode:AVAudioSessionModeVoicePrompt
options:AVAudioSessionCategoryOptionInterruptSpokenAudioAndMixWithOthers |
AVAudioSessionCategoryOptionDuckOthers
error:&err]) {
LOG(LWARNING, ("[ setCategory]] error.", [err localizedDescription]));
LOG(LWARNING, ("Couldn't configure audio session: ", [err localizedDescription]));
}
// Set initial StreetNamesTTS setting
@ -240,18 +241,11 @@ using Observers = NSHashTable<Observer>;
stopSession();
return;
} else {
AVAudioSessionMode mode = AVAudioSessionModeDefault;
if ([MWMCarPlayService shared].isCarplayActivated) {
mode = AVAudioSessionModeVoicePrompt;
}
if (![[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback
mode:mode
options:
AVAudioSessionCategoryOptionInterruptSpokenAudioAndMixWithOthers |
AVAudioSessionCategoryOptionDuckOthers
error:nil] ||
![[AVAudioSession sharedInstance] setActive:YES error:nil])
NSError * err = nil;
if (![[AVAudioSession sharedInstance] setActive:YES error:&err]) {
LOG(LWARNING, ("Couldn't active audio session: ", [err localizedDescription]));
return;
}
for (NSString * notification in turnNotifications)
[self speakOneString:notification];