From 54c42b276f0adc943cb3cc08d8aa0c173a95e07b Mon Sep 17 00:00:00 2001 From: Jonas Kvinge Date: Mon, 13 Nov 2023 00:11:00 +0100 Subject: [PATCH] GstEnginePipeline: Increase thread priority --- CMakeLists.txt | 4 ++-- src/engine/gstenginepipeline.cpp | 23 ++++++++++++++++------- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9095c2d3b..1d13c6f1d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -102,12 +102,12 @@ endif() option(USE_ICU "Use ICU" ON) find_package(PkgConfig REQUIRED) -find_package(Boost REQUIRED) -find_package(Threads) +find_package(Threads REQUIRED) find_package(Backtrace) if(Backtrace_FOUND) set(HAVE_BACKTRACE ON) endif() +find_package(Boost REQUIRED) if(USE_ICU) find_package(ICU COMPONENTS uc i18n REQUIRED) if(ICU_FOUND) diff --git a/src/engine/gstenginepipeline.cpp b/src/engine/gstenginepipeline.cpp index 74e4ac720..1dd3391ac 100644 --- a/src/engine/gstenginepipeline.cpp +++ b/src/engine/gstenginepipeline.cpp @@ -21,6 +21,8 @@ #include "config.h" +#include + #include #include #include @@ -30,7 +32,13 @@ #include #include -#include +#ifdef Q_OS_UNIX +# include +#endif +#ifdef Q_OS_WIN32 +# include +#endif + #include #include #include @@ -1288,16 +1296,17 @@ void GstEnginePipeline::TaskEnterCallback(GstTask *task, GThread *thread, gpoint Q_UNUSED(thread) Q_UNUSED(self) - // Bump the priority of the thread only on macOS - -#ifdef Q_OS_MACOS - sched_param param; +#ifdef Q_OS_UNIX + sched_param param{}; memset(¶m, 0, sizeof(param)); - - param.sched_priority = 99; + param.sched_priority = 40; pthread_setschedparam(pthread_self(), SCHED_RR, ¶m); #endif +#ifdef Q_OS_WIN32 + SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_HIGHEST); +#endif + } void GstEnginePipeline::ElementMessageReceived(GstMessage *msg) {