UI: Make workaround for Logitech plugin hard lock

In commit d17ee20863, we attempted to fix a race condition crash in the
Logitech plugin by deferring the "stream/recording/replay buffer active"
calls to the UI thread.  However, the Logitech plugin loop_function
funciton can call obs_frontend_streaming_active/etc functions while the
UI thread waits for the loop_function thread for many OBS events,
causing a hard lock in the Logitech plugin.  This fixes that by making
the obs_frontend_streaming_active/etc functions completely atomic
instead.  It's a bit of a hack but it's better than accessing objects.
This commit is contained in:
jp9000
2019-02-26 06:37:01 -08:00
parent 484c3847fc
commit 1c4a6ca6c6
2 changed files with 17 additions and 18 deletions

View File

@@ -20,6 +20,10 @@ static T GetOBSRef(QListWidgetItem *item)
void EnumProfiles(function<bool (const char *, const char *)> &&cb);
void EnumSceneCollections(function<bool (const char *, const char *)> &&cb);
extern volatile bool streaming_active;
extern volatile bool recording_active;
extern volatile bool replaybuf_active;
/* ------------------------------------------------------------------------- */
template<typename T> struct OBSStudioCallback {
@@ -232,12 +236,7 @@ struct OBSStudioAPI : obs_frontend_callbacks {
bool obs_frontend_streaming_active(void) override
{
bool active;
QMetaObject::invokeMethod(main,
"StreamingActive",
WaitConnection(),
Q_RETURN_ARG(bool, active));
return active;
return os_atomic_load_bool(&streaming_active);
}
void obs_frontend_recording_start(void) override
@@ -252,12 +251,7 @@ struct OBSStudioAPI : obs_frontend_callbacks {
bool obs_frontend_recording_active(void) override
{
bool active;
QMetaObject::invokeMethod(main,
"RecordingActive",
WaitConnection(),
Q_RETURN_ARG(bool, active));
return active;
return os_atomic_load_bool(&recording_active);
}
void obs_frontend_replay_buffer_start(void) override
@@ -277,12 +271,7 @@ struct OBSStudioAPI : obs_frontend_callbacks {
bool obs_frontend_replay_buffer_active(void) override
{
bool active;
QMetaObject::invokeMethod(main,
"ReplayBufferActive",
WaitConnection(),
Q_RETURN_ARG(bool, active));
return active;
return os_atomic_load_bool(&replaybuf_active);
}
void *obs_frontend_add_tools_menu_qaction(const char *name) override