From 8e0ffb4d3ce1ab412b8ad5dca65864ce6874176c Mon Sep 17 00:00:00 2001 From: eddyStreamlabs Date: Wed, 24 Oct 2018 13:42:37 -0700 Subject: [PATCH] Add new exported function to terminate the crash handler --- obs-studio-client/source/nodeobs_api.cpp | 14 +++++++++++++- obs-studio-client/source/nodeobs_api.hpp | 1 + obs-studio-server/source/nodeobs_api.cpp | 14 +++++++++++++- obs-studio-server/source/nodeobs_api.h | 5 +++++ 4 files changed, 32 insertions(+), 2 deletions(-) diff --git a/obs-studio-client/source/nodeobs_api.cpp b/obs-studio-client/source/nodeobs_api.cpp index 5523ef5d4..05da79f04 100644 --- a/obs-studio-client/source/nodeobs_api.cpp +++ b/obs-studio-client/source/nodeobs_api.cpp @@ -1,6 +1,6 @@ -#include "nodeobs_api.hpp" #include "controller.hpp" #include "error.hpp" +#include "nodeobs_api.hpp" #include "utility-v8.hpp" #include @@ -141,6 +141,17 @@ void api::SetWorkingDirectory(const v8::FunctionCallbackInfo& args) ValidateResponse(response); } +void api::StopCrashHandler(const v8::FunctionCallbackInfo& args) +{ + auto conn = GetConnection(); + if (!conn) + return; + + std::vector response = conn->call_synchronous_helper("API", "StopCrashHandler", {}); + + ValidateResponse(response); +} + INITIALIZER(nodeobs_api) { initializerFunctions.push([](v8::Local exports) { @@ -152,5 +163,6 @@ INITIALIZER(nodeobs_api) exports, "OBS_API_getOBS_existingSceneCollections", api::OBS_API_getOBS_existingSceneCollections); NODE_SET_METHOD(exports, "OBS_API_isOBS_installed", api::OBS_API_isOBS_installed); NODE_SET_METHOD(exports, "SetWorkingDirectory", api::SetWorkingDirectory); + NODE_SET_METHOD(exports, "StopCrashHandler", api::StopCrashHandler); }); } diff --git a/obs-studio-client/source/nodeobs_api.hpp b/obs-studio-client/source/nodeobs_api.hpp index 6e04aedcc..f6e8f1e24 100644 --- a/obs-studio-client/source/nodeobs_api.hpp +++ b/obs-studio-client/source/nodeobs_api.hpp @@ -11,4 +11,5 @@ namespace api static void OBS_API_getOBS_existingSceneCollections(const v8::FunctionCallbackInfo& args); static void OBS_API_isOBS_installed(const v8::FunctionCallbackInfo& args); static void SetWorkingDirectory(const v8::FunctionCallbackInfo& args); + static void StopCrashHandler(const v8::FunctionCallbackInfo& args); } // namespace api diff --git a/obs-studio-server/source/nodeobs_api.cpp b/obs-studio-server/source/nodeobs_api.cpp index 7bec9d9ab..9bc2fc2c8 100644 --- a/obs-studio-server/source/nodeobs_api.cpp +++ b/obs-studio-server/source/nodeobs_api.cpp @@ -63,6 +63,8 @@ void OBS_API::Register(ipc::server& srv) std::make_shared("OBS_API_isOBS_installed", std::vector{}, OBS_API_isOBS_installed)); cls->register_function(std::make_shared( "SetWorkingDirectory", std::vector{ipc::type::String}, SetWorkingDirectory)); + cls->register_function(std::make_shared( + "StopCrashHandler", std::vector{}, StopCrashHandler)); srv.register_collection(cls); } @@ -800,11 +802,21 @@ static void SaveProfilerData(const profiler_snapshot_t* snap) blog(LOG_WARNING, "Could not save profiler data to '%s'", dst.c_str()); } -void OBS_API::destroyOBS_API(void) +void OBS_API::StopCrashHandler( + void* data, + const int64_t id, + const std::vector& args, + std::vector& rval) { writeCrashHandler(unregisterProcess()); writeCrashHandler(terminateCrashHandler()); + rval.push_back(ipc::value((uint64_t)ErrorCode::Ok)); + AUTO_DEBUG; +} + +void OBS_API::destroyOBS_API(void) +{ os_cpu_usage_info_destroy(cpuUsageInfo); #ifdef _WIN32 diff --git a/obs-studio-server/source/nodeobs_api.h b/obs-studio-server/source/nodeobs_api.h index f20216c51..4beccdbc2 100644 --- a/obs-studio-server/source/nodeobs_api.h +++ b/obs-studio-server/source/nodeobs_api.h @@ -63,6 +63,11 @@ class OBS_API const int64_t id, const std::vector& args, std::vector& rval); + static void StopCrashHandler( + void* data, + const int64_t id, + const std::vector& args, + std::vector& rval); private: static void initAPI(void);