libobs: Add task scheduling features

(This commit also modifies the UI)

Adds the ability to schedule tasks for certain threads
This commit is contained in:
jp9000
2020-03-14 10:39:24 -07:00
parent 9f00350688
commit 8de20ab3be
6 changed files with 142 additions and 0 deletions

View File

@@ -1327,6 +1327,17 @@ void OBSApp::Exec(VoidFunc func)
func();
}
static void ui_task_handler(obs_task_t task, void *param, bool wait)
{
auto doTask = [=]() {
/* to get clang-format to behave */
task(param);
};
QMetaObject::invokeMethod(App(), "Exec",
wait ? WaitConnection() : Qt::AutoConnection,
Q_ARG(VoidFunc, doTask));
}
bool OBSApp::OBSInit()
{
ProfileScope("OBSApp::OBSInit");
@@ -1338,6 +1349,8 @@ bool OBSApp::OBSInit()
if (!StartupOBS(locale.c_str(), GetProfilerNameStore()))
return false;
obs_set_ui_task_handler(ui_task_handler);
#ifdef _WIN32
bool browserHWAccel =
config_get_bool(globalConfig, "General", "BrowserHWAccel");

View File

@@ -2267,6 +2267,9 @@ void OBSBasic::ClearHotkeys()
OBSBasic::~OBSBasic()
{
/* clear out UI event queue */
QApplication::sendPostedEvents(App());
if (updateCheckThread && updateCheckThread->isRunning())
updateCheckThread->wait();