Skip to content

Commit 6fbe36f

Browse files
Adds handling of open command via pipe.
1 parent 632b395 commit 6fbe36f

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

src/elgato-cloud-data.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,18 +59,41 @@ std::unique_lock<std::mutex> *GetElgatoCloudLoopLock()
5959

6060
ElgatoCloud::ElgatoCloud(obs_module_t *m)
6161
{
62+
_openOnLaunch = false;
63+
_obsReady = false;
6264
_modulePtr = m;
6365
//_translate = t;
6466
_securerand = QRandomGenerator::securelySeeded();
67+
obs_frontend_add_event_callback(ElgatoCloud::FrontEndEventHandler, this);
6568
_Initialize();
6669
_Listen();
6770
}
6871

6972
ElgatoCloud::~ElgatoCloud()
7073
{
74+
obs_frontend_remove_event_callback(ElgatoCloud::FrontEndEventHandler, this);
7175
obs_data_release(_config);
7276
}
7377

78+
void ElgatoCloud::FrontEndEventHandler(enum obs_frontend_event event, void* data)
79+
{
80+
auto ec = static_cast<ElgatoCloud*>(data);
81+
switch (event) {
82+
case OBS_FRONTEND_EVENT_FINISHED_LOADING:
83+
ec->_obsReady = true;
84+
if (ec->_openOnLaunch) {
85+
ec->_openOnLaunch = false;
86+
QMetaObject::invokeMethod(
87+
QCoreApplication::instance()
88+
->thread(),
89+
[ec]() {
90+
OpenElgatoCloudWindow();
91+
});
92+
}
93+
break;
94+
}
95+
}
96+
7497
obs_data_t *ElgatoCloud::GetConfig()
7598
{
7699
obs_data_addref(_config);
@@ -246,6 +269,10 @@ void ElgatoCloud::_Listen()
246269
else if (d.find("elgatolink://open") == 0)
247270
{
248271
obs_log(LOG_INFO, "OPEN COMMAND RECEIEVED!");
272+
if (!_obsReady) {
273+
_openOnLaunch = true;
274+
return;
275+
}
249276
if (mainWindowOpen && window) {
250277
QMetaObject::invokeMethod(
251278
QCoreApplication::instance()

src/elgato-cloud-data.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ with this program. If not, see <https://www.gnu.org/licenses/>
1919
#pragma once
2020

2121
#include <obs-module.h>
22+
#include <obs-frontend-api.h>
2223

2324
#include <mutex>
2425
#include <thread>
@@ -72,6 +73,7 @@ class ElgatoCloud {
7273
bool mainWindowOpen = false;
7374
ElgatoCloudWindow *window = nullptr;
7475
inline bool MakerToolsOnStart() const { return _makerToolsOnStart; }
76+
static void FrontEndEventHandler(enum obs_frontend_event event, void* data);
7577

7678
private:
7779
void _Initialize();
@@ -95,6 +97,8 @@ class ElgatoCloud {
9597
std::string _skipUpdate;
9698
obs_data_t *_config;
9799
bool _makerToolsOnStart;
100+
bool _openOnLaunch;
101+
bool _obsReady;
98102
};
99103

100104
class ElgatoCloudThread : public QThread {

0 commit comments

Comments
 (0)