提交 d17ee208 编写于 作者: J jp9000

obs-frontend-api: Make a few frontend API thread-safe

Additionally, check for null output handlers.
上级 9cf40e23
...@@ -232,7 +232,12 @@ struct OBSStudioAPI : obs_frontend_callbacks { ...@@ -232,7 +232,12 @@ struct OBSStudioAPI : obs_frontend_callbacks {
bool obs_frontend_streaming_active(void) override bool obs_frontend_streaming_active(void) override
{ {
return main->outputHandler->StreamingActive(); bool active;
QMetaObject::invokeMethod(main,
"StreamingActive",
WaitConnection(),
Q_RETURN_ARG(bool, active));
return active;
} }
void obs_frontend_recording_start(void) override void obs_frontend_recording_start(void) override
...@@ -247,7 +252,12 @@ struct OBSStudioAPI : obs_frontend_callbacks { ...@@ -247,7 +252,12 @@ struct OBSStudioAPI : obs_frontend_callbacks {
bool obs_frontend_recording_active(void) override bool obs_frontend_recording_active(void) override
{ {
return main->outputHandler->RecordingActive(); bool active;
QMetaObject::invokeMethod(main,
"RecordingActive",
WaitConnection(),
Q_RETURN_ARG(bool, active));
return active;
} }
void obs_frontend_replay_buffer_start(void) override void obs_frontend_replay_buffer_start(void) override
...@@ -267,7 +277,12 @@ struct OBSStudioAPI : obs_frontend_callbacks { ...@@ -267,7 +277,12 @@ struct OBSStudioAPI : obs_frontend_callbacks {
bool obs_frontend_replay_buffer_active(void) override bool obs_frontend_replay_buffer_active(void) override
{ {
return main->outputHandler->ReplayBufferActive(); bool active;
QMetaObject::invokeMethod(main,
"ReplayBufferActive",
WaitConnection(),
Q_RETURN_ARG(bool, active));
return active;
} }
void *obs_frontend_add_tools_menu_qaction(const char *name) override void *obs_frontend_add_tools_menu_qaction(const char *name) override
......
...@@ -6998,3 +6998,24 @@ OBSBasic *OBSBasic::Get() ...@@ -6998,3 +6998,24 @@ OBSBasic *OBSBasic::Get()
{ {
return reinterpret_cast<OBSBasic*>(App()->GetMainWindow()); return reinterpret_cast<OBSBasic*>(App()->GetMainWindow());
} }
bool OBSBasic::StreamingActive()
{
if (!outputHandler)
return false;
return outputHandler->StreamingActive();
}
bool OBSBasic::RecordingActive()
{
if (!outputHandler)
return false;
return outputHandler->RecordingActive();
}
bool OBSBasic::ReplayBufferActive()
{
if (!outputHandler)
return false;
return outputHandler->ReplayBufferActive();
}
...@@ -789,6 +789,10 @@ private slots: ...@@ -789,6 +789,10 @@ private slots:
public slots: public slots:
void on_actionResetTransform_triggered(); void on_actionResetTransform_triggered();
bool StreamingActive();
bool RecordingActive();
bool ReplayBufferActive();
public: public:
explicit OBSBasic(QWidget *parent = 0); explicit OBSBasic(QWidget *parent = 0);
virtual ~OBSBasic(); virtual ~OBSBasic();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册