Skip to content

Commit

Permalink
Clean up config files
Browse files Browse the repository at this point in the history
 - Fix memory leaks
 - Handle config files through a Singleton
 - Remove dead code
 - Fix potential crashes
  • Loading branch information
EddyGharbi committed Nov 5, 2018
1 parent e9b9aee commit ce7f4a3
Show file tree
Hide file tree
Showing 12 changed files with 845 additions and 1,636 deletions.
63 changes: 1 addition & 62 deletions obs-studio-client/source/nodeobs_api.cpp
Expand Up @@ -71,64 +71,7 @@ void api::OBS_API_getPerformanceStatistics(const v8::FunctionCallbackInfo<v8::Va
return;
}

void api::OBS_API_getOBS_existingProfiles(const v8::FunctionCallbackInfo<v8::Value>& args)
{
auto conn = GetConnection();
if (!conn)
return;

std::vector<ipc::value> response = conn->call_synchronous_helper("API", "OBS_API_getOBS_existingProfiles", {});

if (!ValidateResponse(response))
return;

v8::Local<v8::Array> existingProfiles = v8::Array::New(args.GetIsolate());

for (int i = 1; i < response.size(); i++) {
existingProfiles->Set(i, v8::String::NewFromUtf8(args.GetIsolate(), response.at(i).value_str.c_str()));
}

args.GetReturnValue().Set(existingProfiles);
}

void api::OBS_API_getOBS_existingSceneCollections(const v8::FunctionCallbackInfo<v8::Value>& args)
{
auto conn = GetConnection();
if (!conn)
return;

std::vector<ipc::value> response =
conn->call_synchronous_helper("API", "OBS_API_getOBS_existingSceneCollections", {});

if (!ValidateResponse(response))
return;

v8::Local<v8::Array> existingSceneCollections = v8::Array::New(args.GetIsolate());

for (int i = 1; i < response.size(); i++) {
existingSceneCollections->Set(i, v8::String::NewFromUtf8(args.GetIsolate(), response.at(i).value_str.c_str()));
}

args.GetReturnValue().Set(existingSceneCollections);
return;
}

void api::OBS_API_isOBS_installed(const v8::FunctionCallbackInfo<v8::Value>& args)
{
auto conn = GetConnection();
if (!conn)
return;

std::vector<ipc::value> response = conn->call_synchronous_helper("API", "OBS_API_isOBS_installed", {});

if (!ValidateResponse(response))
return;

args.GetReturnValue().Set(utilv8::ToValue(response[1].value_union.ui32));
}

void api::SetWorkingDirectory(const v8::FunctionCallbackInfo<v8::Value>& args)
{
void api::SetWorkingDirectory(const v8::FunctionCallbackInfo<v8::Value>& args) {
Nan::Utf8String param0(args[0]);
std::string path = *param0;

Expand All @@ -147,10 +90,6 @@ INITIALIZER(nodeobs_api)
NODE_SET_METHOD(exports, "OBS_API_initAPI", api::OBS_API_initAPI);
NODE_SET_METHOD(exports, "OBS_API_destroyOBS_API", api::OBS_API_destroyOBS_API);
NODE_SET_METHOD(exports, "OBS_API_getPerformanceStatistics", api::OBS_API_getPerformanceStatistics);
NODE_SET_METHOD(exports, "OBS_API_getOBS_existingProfiles", api::OBS_API_getOBS_existingProfiles);
NODE_SET_METHOD(
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);
});
}
3 changes: 0 additions & 3 deletions obs-studio-client/source/nodeobs_api.hpp
Expand Up @@ -7,8 +7,5 @@ namespace api
static void OBS_API_initAPI(const v8::FunctionCallbackInfo<v8::Value>& args);
static void OBS_API_destroyOBS_API(const v8::FunctionCallbackInfo<v8::Value>& args);
static void OBS_API_getPerformanceStatistics(const v8::FunctionCallbackInfo<v8::Value>& args);
static void OBS_API_getOBS_existingProfiles(const v8::FunctionCallbackInfo<v8::Value>& args);
static void OBS_API_getOBS_existingSceneCollections(const v8::FunctionCallbackInfo<v8::Value>& args);
static void OBS_API_isOBS_installed(const v8::FunctionCallbackInfo<v8::Value>& args);
static void SetWorkingDirectory(const v8::FunctionCallbackInfo<v8::Value>& args);
} // namespace api
1 change: 1 addition & 0 deletions obs-studio-server/CMakeLists.txt
Expand Up @@ -185,6 +185,7 @@ SET(PROJECT_SOURCE
"${PROJECT_SOURCE_DIR}/source/nodeobs_api.cpp" "${PROJECT_SOURCE_DIR}/source/nodeobs_api.h"
"${PROJECT_SOURCE_DIR}/source/nodeobs_audio_encoders.cpp" "${PROJECT_SOURCE_DIR}/source/nodeobs_audio_encoders.h"
"${PROJECT_SOURCE_DIR}/source/nodeobs_autoconfig.cpp" "${PROJECT_SOURCE_DIR}/source/nodeobs_autoconfig.h"
"${PROJECT_SOURCE_DIR}/source/nodeobs_configManager.cpp" "${PROJECT_SOURCE_DIR}/source/nodeobs_configManager.hpp"
###### "${PROJECT_SOURCE_DIR}/source/nodeobs_async.h"
"${PROJECT_SOURCE_DIR}/source/nodeobs_display.cpp" "${PROJECT_SOURCE_DIR}/source/nodeobs_display.h"
"${PROJECT_SOURCE_DIR}/source/nodeobs_content.h" "${PROJECT_SOURCE_DIR}/source/nodeobs_common.cpp"
Expand Down

0 comments on commit ce7f4a3

Please sign in to comment.