Skip to content

Commit

Permalink
macOS related fixes
Browse files Browse the repository at this point in the history
Signed-off-by: falkTX <[email protected]>
  • Loading branch information
falkTX committed Mar 26, 2024
1 parent d2a9dc5 commit c46c1b1
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 16 deletions.
7 changes: 0 additions & 7 deletions common/JackClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -639,13 +639,6 @@ 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 {
Expand Down
11 changes: 3 additions & 8 deletions macosx/JackMachThread.mm
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
#endif
theTCPolicy.preemptible = true;
kern_return_t res = thread_policy_set(pthread_mach_thread_np(thread), THREAD_TIME_CONSTRAINT_POLICY, (thread_policy_t) &theTCPolicy, THREAD_TIME_CONSTRAINT_POLICY_COUNT);
jack_log("JackMachThread::thread_policy_set res = %ld", res);
jack_log("JackMachThread::thread_policy_set RT res = %ld", res);
return (res == KERN_SUCCESS) ? 0 : -1;
} else {
// OTHER THREADS
Expand All @@ -69,7 +69,7 @@

thePrecedencePolicy.importance = relativePriority;
kern_return_t res = thread_policy_set(pthread_mach_thread_np(thread), THREAD_PRECEDENCE_POLICY, (thread_policy_t) &thePrecedencePolicy, THREAD_PRECEDENCE_POLICY_COUNT);
jack_log("JackMachThread::thread_policy_set res = %ld", res);
jack_log("JackMachThread::thread_policy_set non-RT res = %ld", res);
return (res == KERN_SUCCESS) ? 0 : -1;
}
}
Expand Down Expand Up @@ -160,21 +160,16 @@

int JackMachThread::Kill()
{
#if 0
// NOTE: starting macOS 12, this code no longer works
if (fThread != (jack_native_thread_t)NULL) { // If thread has been started
jack_log("JackMachThread::Kill");
mach_port_t machThread = pthread_mach_thread_np(fThread);
int res = (thread_terminate(machThread) == KERN_SUCCESS) ? 0 : -1;
int res = (thread_abort(machThread) == KERN_SUCCESS) ? 0 : -1;
fStatus = kIdle;
fThread = (jack_native_thread_t)NULL;
return res;
} else {
return -1;
}
#else
return JackPosixThread::Kill();
#endif
}

int JackMachThread::AcquireRealTime()
Expand Down
2 changes: 1 addition & 1 deletion posix/JackSocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ int JackClientSocket::Read(void* data, int len)
jack_error("Cannot read socket fd = %d res = %d err = %s", fSocket, res, strerror(errno));
//return 0;
return -1;
} else if (errno == 0) {
} else if (errno == 0 || errno == ENOTCONN) {
// aborted reading due to shutdown
return JACK_REQUEST_ERR_ABORTED;
} else {
Expand Down

0 comments on commit c46c1b1

Please sign in to comment.