mirror of
https://github.com/Palakis/obs-websocket.git
synced 2024-08-30 18:12:16 +00:00
WSEvents: connect to signals at construct and disconnect at destroy
This commit is contained in:
parent
6c85b33539
commit
3d9eac8e6d
@ -114,6 +114,13 @@ WSEvents::WSEvents(WSServerPtr srv) :
|
||||
|
||||
heartbeatTimer.start(STATUS_INTERVAL);
|
||||
|
||||
// Connect to signals of all existing sources
|
||||
obs_enum_sources([](void* param, obs_source_t* source) {
|
||||
auto self = reinterpret_cast<WSEvents*>(param);
|
||||
self->connectSourceSignals(source);
|
||||
return true;
|
||||
}, this);
|
||||
|
||||
signal_handler_t* coreSignalHandler = obs_get_signal_handler();
|
||||
if (coreSignalHandler) {
|
||||
signal_handler_connect(coreSignalHandler, "source_create", OnSourceCreate, this);
|
||||
@ -128,6 +135,13 @@ WSEvents::~WSEvents() {
|
||||
signal_handler_disconnect(coreSignalHandler, "source_create", OnSourceCreate, this);
|
||||
}
|
||||
|
||||
// Disconnect from signals of all existing sources
|
||||
obs_enum_sources([](void* param, obs_source_t* source) {
|
||||
auto self = reinterpret_cast<WSEvents*>(param);
|
||||
self->disconnectSourceSignals(source);
|
||||
return true;
|
||||
}, this);
|
||||
|
||||
obs_frontend_remove_event_callback(WSEvents::FrontendEventHandler, this);
|
||||
os_cpu_usage_info_destroy(cpuUsageInfo);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user