Skip to content

Commit 8e0ffb4

Browse files
author
eddyStreamlabs
committed
Add new exported function to terminate the crash handler
1 parent 6b0bfd8 commit 8e0ffb4

File tree

4 files changed

+32
-2
lines changed

4 files changed

+32
-2
lines changed

obs-studio-client/source/nodeobs_api.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#include "nodeobs_api.hpp"
21
#include "controller.hpp"
32
#include "error.hpp"
3+
#include "nodeobs_api.hpp"
44
#include "utility-v8.hpp"
55

66
#include <node.h>
@@ -141,6 +141,17 @@ void api::SetWorkingDirectory(const v8::FunctionCallbackInfo<v8::Value>& args)
141141
ValidateResponse(response);
142142
}
143143

144+
void api::StopCrashHandler(const v8::FunctionCallbackInfo<v8::Value>& args)
145+
{
146+
auto conn = GetConnection();
147+
if (!conn)
148+
return;
149+
150+
std::vector<ipc::value> response = conn->call_synchronous_helper("API", "StopCrashHandler", {});
151+
152+
ValidateResponse(response);
153+
}
154+
144155
INITIALIZER(nodeobs_api)
145156
{
146157
initializerFunctions.push([](v8::Local<v8::Object> exports) {
@@ -152,5 +163,6 @@ INITIALIZER(nodeobs_api)
152163
exports, "OBS_API_getOBS_existingSceneCollections", api::OBS_API_getOBS_existingSceneCollections);
153164
NODE_SET_METHOD(exports, "OBS_API_isOBS_installed", api::OBS_API_isOBS_installed);
154165
NODE_SET_METHOD(exports, "SetWorkingDirectory", api::SetWorkingDirectory);
166+
NODE_SET_METHOD(exports, "StopCrashHandler", api::StopCrashHandler);
155167
});
156168
}

obs-studio-client/source/nodeobs_api.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@ namespace api
1111
static void OBS_API_getOBS_existingSceneCollections(const v8::FunctionCallbackInfo<v8::Value>& args);
1212
static void OBS_API_isOBS_installed(const v8::FunctionCallbackInfo<v8::Value>& args);
1313
static void SetWorkingDirectory(const v8::FunctionCallbackInfo<v8::Value>& args);
14+
static void StopCrashHandler(const v8::FunctionCallbackInfo<v8::Value>& args);
1415
} // namespace api

obs-studio-server/source/nodeobs_api.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ void OBS_API::Register(ipc::server& srv)
6363
std::make_shared<ipc::function>("OBS_API_isOBS_installed", std::vector<ipc::type>{}, OBS_API_isOBS_installed));
6464
cls->register_function(std::make_shared<ipc::function>(
6565
"SetWorkingDirectory", std::vector<ipc::type>{ipc::type::String}, SetWorkingDirectory));
66+
cls->register_function(std::make_shared<ipc::function>(
67+
"StopCrashHandler", std::vector<ipc::type>{}, StopCrashHandler));
6668

6769
srv.register_collection(cls);
6870
}
@@ -800,11 +802,21 @@ static void SaveProfilerData(const profiler_snapshot_t* snap)
800802
blog(LOG_WARNING, "Could not save profiler data to '%s'", dst.c_str());
801803
}
802804

803-
void OBS_API::destroyOBS_API(void)
805+
void OBS_API::StopCrashHandler(
806+
void* data,
807+
const int64_t id,
808+
const std::vector<ipc::value>& args,
809+
std::vector<ipc::value>& rval)
804810
{
805811
writeCrashHandler(unregisterProcess());
806812
writeCrashHandler(terminateCrashHandler());
807813

814+
rval.push_back(ipc::value((uint64_t)ErrorCode::Ok));
815+
AUTO_DEBUG;
816+
}
817+
818+
void OBS_API::destroyOBS_API(void)
819+
{
808820
os_cpu_usage_info_destroy(cpuUsageInfo);
809821

810822
#ifdef _WIN32

obs-studio-server/source/nodeobs_api.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,11 @@ class OBS_API
6363
const int64_t id,
6464
const std::vector<ipc::value>& args,
6565
std::vector<ipc::value>& rval);
66+
static void StopCrashHandler(
67+
void* data,
68+
const int64_t id,
69+
const std::vector<ipc::value>& args,
70+
std::vector<ipc::value>& rval);
6671

6772
private:
6873
static void initAPI(void);

0 commit comments

Comments
 (0)