Skip to content

Commit 1dd60bf

Browse files
committed
return error messaging from Apple system extension
* update mac-virtualcam code path to return output if an error occurs
1 parent 9efed44 commit 1dd60bf

File tree

5 files changed

+22
-20
lines changed

5 files changed

+22
-20
lines changed

obs-studio-client/source/nodeobs_service.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ Napi::Value service::OBS_service_updateVirtualCam(const Napi::CallbackInfo &info
422422

423423
Napi::Value service::OBS_service_installVirtualCamPlugin(const Napi::CallbackInfo &info)
424424
{
425-
bool isInstalled = true;
425+
std::string message;
426426
#ifdef WIN32
427427
SHELLEXECUTEINFO ShExecInfo = {0};
428428
ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);
@@ -442,9 +442,9 @@ Napi::Value service::OBS_service_installVirtualCamPlugin(const Napi::CallbackInf
442442
CloseHandle(ShExecInfo.hProcess);
443443

444444
#elif __APPLE__
445-
isInstalled = g_util_osx->installPlugin();
445+
message = g_util_osx->installPlugin();
446446
#endif
447-
return Napi::Boolean::New(info.Env(), isInstalled);
447+
return Napi::String::New(info.Env(), message);
448448
}
449449

450450
Napi::Value service::OBS_service_uninstallVirtualCamPlugin(const Napi::CallbackInfo &info)

obs-studio-client/source/util-osx-impl.mm

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ void uninstallLegacyDALPlugin()
3838
}
3939
}
4040

41-
bool executeTaskAndCaptureOutput(const std::string &path, NSArray<NSString *> *exeArguments = nullptr)
41+
std::string executeTaskAndCaptureOutput(const std::string &path, NSArray<NSString *> *exeArguments = nullptr)
4242
{
43-
bool success = true;
43+
std::string errorMessage;
4444
@autoreleasepool {
4545
@try {
4646
// Create an NSTask instance
@@ -71,16 +71,19 @@ bool executeTaskAndCaptureOutput(const std::string &path, NSArray<NSString *> *e
7171
NSString *outputString = [[NSString alloc] initWithData:outputData encoding:NSUTF8StringEncoding];
7272

7373
// Print the captured output
74-
std::cout << "Child process output:\n" << [outputString UTF8String] << std::endl;
74+
if (exitCode != 0) {
75+
errorMessage = outputString.UTF8String;
76+
}
77+
std::cout << "Child process output:\n" << outputString.UTF8String << std::endl;
7578
std::cout << "Child process exited with code: " << exitCode << std::endl;
7679
} @catch (NSException *exception) {
7780
std::cout << "Caught an NSException!" << std::endl;
7881
std::cout << "Name: " << [[exception name] UTF8String] << std::endl;
7982
std::cout << "Reason: " << [[exception reason] UTF8String] << std::endl;
80-
success = false;
83+
errorMessage = [[exception reason] UTF8String];
8184
}
8285
}
83-
return success;
86+
return errorMessage;
8487
}
8588

8689
// In our app bundle, we will search for the slobs-virtual-cam-installer.app which
@@ -169,19 +172,18 @@ bool replace(std::string &str, const std::string &from, const std::string &to)
169172
return true;
170173
}
171174

172-
bool UtilObjCInt::installPlugin()
175+
std::string UtilObjCInt::installPlugin()
173176
{
174177
const std::string path = getInstallerAppPath();
175178
return executeTaskAndCaptureOutput(path); // Run the installer
176179
}
177180

178-
void UtilObjCInt::uninstallPlugin()
181+
std::string UtilObjCInt::uninstallPlugin()
179182
{
183+
uninstallLegacyDALPlugin();
180184
// Uninstall the camera system extension
181185
const std::string path = getInstallerAppPath();
182186
return executeTaskAndCaptureOutput(path, @[@"--deactivate"]); // Run the uninstaller
183-
184-
uninstallLegacyDALPlugin();
185187
}
186188

187189
bool UtilObjCInt::isPluginInstalled()

obs-studio-client/source/util-osx-int.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ class UtilObjCInt {
3737
void init(void);
3838
void getPermissionsStatus(bool &webcam, bool &mic);
3939
void requestPermissions(void *async_cb, perms_cb cb);
40-
bool installPlugin(void);
41-
void uninstallPlugin(void);
40+
std::string installPlugin(void);
41+
std::string uninstallPlugin(void);
4242
void setServerWorkingDirectoryPath(std::string path);
4343
bool isPluginInstalled();
4444

obs-studio-client/source/util-osx.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,14 @@ void UtilInt::requestPermissions(void *async_cb, perms_cb cb)
4444
_impl->requestPermissions(async_cb, cb);
4545
}
4646

47-
bool UtilInt::installPlugin(void)
47+
std::string UtilInt::installPlugin(void)
4848
{
49-
_impl->installPlugin();
49+
return _impl->installPlugin();
5050
}
5151

52-
void UtilInt::uninstallPlugin(void)
52+
std::string UtilInt::uninstallPlugin(void)
5353
{
54-
_impl->uninstallPlugin();
54+
return _impl->uninstallPlugin();
5555
}
5656

5757
void UtilInt::setServerWorkingDirectoryPath(std::string path)

obs-studio-client/source/util-osx.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ class UtilInt {
3333
void init(void);
3434
void getPermissionsStatus(bool &webcam, bool &mic);
3535
void requestPermissions(void *async_cb, perms_cb cb);
36-
bool installPlugin(void);
37-
void uninstallPlugin(void);
36+
std::string installPlugin(void);
37+
std::string uninstallPlugin(void);
3838
void setServerWorkingDirectoryPath(std::string path);
3939
bool isPluginInstalled();
4040

0 commit comments

Comments
 (0)