Skip to content

Commit

Permalink
GstEnginePipeline: Increase thread priority
Browse files Browse the repository at this point in the history
  • Loading branch information
jonaski committed Nov 15, 2023
1 parent 8e4b4d6 commit 9cf63f4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
23 changes: 16 additions & 7 deletions src/engine/gstenginepipeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@

#include "config.h"

#include <QtGlobal>

#include <cstdint>
#include <cstring>
#include <cmath>
Expand All @@ -30,7 +32,13 @@
#include <gst/gst.h>
#include <gst/audio/audio.h>

#include <QtGlobal>
#ifdef Q_OS_UNIX
# include <pthread.h>
#endif
#ifdef Q_OS_WIN32
# include <windows.h>
#endif

#include <QObject>
#include <QCoreApplication>
#include <QtConcurrent>
Expand Down Expand Up @@ -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(&param, 0, sizeof(param));

param.sched_priority = 99;
param.sched_priority = 40;
pthread_setschedparam(pthread_self(), SCHED_RR, &param);
#endif

#ifdef Q_OS_WIN32
SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL);
#endif

}

void GstEnginePipeline::ElementMessageReceived(GstMessage *msg) {
Expand Down

0 comments on commit 9cf63f4

Please sign in to comment.