summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfalkTX <falktx@falktx.com>2023-01-30 22:10:44 +0100
committerfalkTX <falktx@falktx.com>2023-01-30 22:14:29 +0100
commitf5a01999faf991d1ca96d35d0ec407b25c349b7a (patch)
treee4114fc15897493e74129af2c43676ac94fd8fec
parentd2d44158f9eb12d79c5e6220c2cb9f24e50d4c3c (diff)
downloadjack2-f5a01999faf991d1ca96d35d0ec407b25c349b7a.tar.gz
macOS: forcely ignore wait failures when closing down
Signed-off-by: falkTX <falktx@falktx.com>
-rw-r--r--common/JackClient.cpp8
-rw-r--r--macosx/JackMachSemaphore.mm17
2 files changed, 21 insertions, 4 deletions
diff --git a/common/JackClient.cpp b/common/JackClient.cpp
index 43de6b3e..74a9dca8 100644
--- a/common/JackClient.cpp
+++ b/common/JackClient.cpp
@@ -1,6 +1,7 @@
/*
Copyright (C) 2001 Paul Davis
Copyright (C) 2004-2008 Grame
+Copyright (C) 2016-2023 Filipe Coelho <falktx@falktx.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
@@ -638,6 +639,13 @@ inline bool JackClient::WaitSync()
{
// Suspend itself: wait on the input synchro
if (GetGraphManager()->SuspendRefNum(GetClientControl(), fSynchroTable, LONG_MAX) < 0) {
+#ifdef __APPLE__
+ // FIXME macOS reports wait failures when closing down, due to aborted semaphore, ignore it
+ if (!GetClientControl()->fActive) {
+ fThread.Terminate();
+ return true;
+ }
+#endif
jack_error("SuspendRefNum error");
return false;
} else {
diff --git a/macosx/JackMachSemaphore.mm b/macosx/JackMachSemaphore.mm
index f2ba3dd7..8b855657 100644
--- a/macosx/JackMachSemaphore.mm
+++ b/macosx/JackMachSemaphore.mm
@@ -1,5 +1,6 @@
/*
Copyright (C) 2004-2008 Grame
+Copyright (C) 2016-2023 Filipe Coelho <falktx@falktx.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
@@ -92,11 +93,15 @@ bool JackMachSemaphore::Wait()
kern_return_t res = semaphore_wait(fSemaphore);
- // killing a thread will abort the semaphore wait
- if (res == KERN_SUCCESS || res == KERN_ABORTED) {
+ if (res == KERN_SUCCESS) {
return true;
}
+ // killing a thread will abort the semaphore wait, skip the error log
+ if (res == KERN_ABORTED) {
+ return false;
+ }
+
jack_error("JackMachSemaphore::Wait name = %s err = %s", fName, mach_error_string(res));
return false;
}
@@ -114,11 +119,15 @@ bool JackMachSemaphore::TimedWait(long usec)
kern_return_t res = semaphore_timedwait(fSemaphore, time);
- // killing a thread will abort the semaphore wait
- if (res == KERN_SUCCESS || res == KERN_ABORTED) {
+ if (res == KERN_SUCCESS) {
return true;
}
+ // killing a thread will abort the semaphore wait, skip the error log
+ if (res == KERN_ABORTED) {
+ return false;
+ }
+
jack_error("JackMachSemaphore::TimedWait name = %s usec = %ld err = %s", fName, usec, mach_error_string(res));
return false;
}