mirror of
https://github.com/obsproject/obs-studio.git
synced 2026-07-13 08:44:29 -04:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user