Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Android thread priority #1280

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
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
9 changes: 9 additions & 0 deletions src/sfizz/FilePool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@
#include <atomic_queue/defs.h>
#if defined(_WIN32)
#include <windows.h>
#elif defined(__ANDROID__)
#include <sys/resource.h>
#else
#include <pthread.h>
#endif
Expand Down Expand Up @@ -609,6 +611,13 @@ void sfz::FilePool::raiseCurrentThreadPriority() noexcept
std::system_error error(GetLastError(), std::system_category());
DBG("[sfizz] Cannot set current thread priority: " << error.what());
}
#elif defined(__ANDROID__)
int tid = gettid(); // Android specific function to get thread ID
int priority = -20; // Highest priority for nice value
if (setpriority(PRIO_PROCESS, tid, priority) != 0) {
// setpriority sets errno on failure
DBG("[sfizz] Cannot set current thread priority: " << strerror(errno));
}
#else
pthread_t thread = pthread_self();
int policy;
Expand Down
Loading