GstEnginePipeline: Increase thread priority

This commit is contained in:
Jonas Kvinge
2023-11-13 00:11:00 +01:00
parent 8e4b4d6e41
commit 54c42b276f
2 changed files with 18 additions and 9 deletions

View File

@@ -21,6 +21,8 @@
#include "config.h"
#include <QtGlobal>
#include <cstdint>
#include <cstring>
#include <cmath>
@@ -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>
@@ -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_HIGHEST);
#endif
}
void GstEnginePipeline::ElementMessageReceived(GstMessage *msg) {