Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 26 additions & 8 deletions bridge/src/fmod_darwin.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,33 @@

static NSTimer * resumeTimer = nil;

// Configure the audio session with the appropriate category for iOS
static void configureAudioSession() {
@autoreleasepool {
NSError * error;

// Set the category to AVAudioSessionCategoryAmbient to allow our app's audio
// to mix with audio from other apps (like music players)
BOOL categorySuccess = [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryAmbient error:&error];

if (!categorySuccess) {
if (error) {
LOGW("Cannot set audio session category: %s", [[error localizedDescription] UTF8String]);
} else {
LOGW("Cannot set audio session category and no error was issued");
}
}
}
}

// In case it doesn't work from the first try, retry activating the audio session
// a few times. For example, after dismissing a phone call, [AVAudioSession setActive: error:]
// errors out from the first try, but works on the second
static void resumeAudioSession(int retries) {
@autoreleasepool {
// Configure the audio session before activating it
configureAudioSession();

NSError * error;
BOOL success = [[AVAudioSession sharedInstance] setActive:TRUE error: &error];
if (success) {
Expand Down Expand Up @@ -46,6 +68,9 @@ static void resumeAudioSession(int retries) {

void FMODBridge_initIOSInterruptionHandler() {
@autoreleasepool {
// Configure the audio session during initialization
configureAudioSession();

[[NSNotificationCenter defaultCenter] addObserverForName:AVAudioSessionInterruptionNotification object:nil queue:nil usingBlock:^(NSNotification *notification) {
NSUInteger typeValue = [[notification.userInfo valueForKey:AVAudioSessionInterruptionTypeKey] intValue];

Expand All @@ -65,12 +90,5 @@ void FMODBridge_initIOSInterruptionHandler() {
}];
}
}
#endif

int FMODBridge_getBundleRoot(lua_State *L) {
@autoreleasepool {
NSString* path = [[NSBundle mainBundle] bundlePath];
lua_pushstring(L, [path UTF8String]);
}
return 1;
}
#endif
Binary file modified fmod/lib/ios/libfmodbridge.a
Binary file not shown.
Binary file modified fmod/lib/x86_64-ios/libfmodbridge_simulator.a
Binary file not shown.