From 9ef27a2c7559f77a5375b4b2a11252c14f32d456 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Sat, 6 Jul 2024 17:37:37 +0900 Subject: [PATCH] audio: make applicationState() thread-safe Closes #3021 --- audio/error_ios.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/audio/error_ios.go b/audio/error_ios.go index d6f6b9bea..404359452 100644 --- a/audio/error_ios.go +++ b/audio/error_ios.go @@ -20,11 +20,14 @@ package audio // #import // // static UIApplicationState applicationState() { -// // Actually this method should be called on the main thread, -// // but there is no way to do that in the current Ebitengine implementation. -// // dispatch_(a)sync causes a deadlock. -// // As this is for an invetigation of iOS errors, that's OK to leave this issue so far. -// return [[UIApplication sharedApplication] applicationState]; +// if ([NSThread isMainThread]) { +// return [[UIApplication sharedApplication] applicationState]; +// } +// __block UIApplicationState state; +// dispatch_sync(dispatch_get_main_queue(), ^{ +// state = [[UIApplication sharedApplication] applicationState]; +// }); +// return state; // } import "C"