@@ -498,8 +498,14 @@ void OBS_API::OBS_API_initAPI(
498498 obs_data_set_bool (private_settings, " BrowserHWAccel" , true );
499499 obs_apply_private_data (private_settings);
500500 obs_data_release (private_settings);
501-
502- openAllModules ();
501+
502+ int videoError;
503+ if (!openAllModules (videoError)) {
504+ rval.push_back (ipc::value ((uint64_t )ErrorCode::Error));
505+ rval.push_back (ipc::value (videoError));
506+ AUTO_DEBUG;
507+ return ;
508+ }
503509
504510 OBS_service::createService ();
505511
@@ -818,9 +824,12 @@ typedef std::basic_string<char, ci_char_traits> istring;
818824
819825/* This should be reusable outside of node-obs, especially
820826* if we go a server/client route. */
821- void OBS_API::openAllModules (void )
827+ bool OBS_API::openAllModules (int & video_err )
822828{
823- OBS_service::resetVideoContext (NULL );
829+ video_err = OBS_service::resetVideoContext (NULL );
830+ if (video_err != OBS_VIDEO_SUCCESS) {
831+ return false ;
832+ }
824833
825834 std::string plugins_paths[] = {g_moduleDirectory + " /obs-plugins/64bit" , g_moduleDirectory + " /obs-plugins" , slobs_plugin + " /obs-plugins/64bit" };
826835
@@ -838,13 +847,13 @@ void OBS_API::openAllModules(void)
838847 * shared library. */
839848 if (!os_file_exists (plugins_path.c_str ())) {
840849 std::cerr << " Plugin Path provided is invalid: " << plugins_path << std::endl;
841- return ;
850+ return false ;
842851 }
843852
844853 os_dir_t * plugin_dir = os_opendir (plugins_path.c_str ());
845854 if (!plugin_dir) {
846855 std::cerr << " Failed to open plugin diretory: " << plugins_path << std::endl;
847- return ;
856+ return false ;
848857 }
849858
850859 for (os_dirent* ent = os_readdir (plugin_dir); ent != nullptr ; ent = os_readdir (plugin_dir)) {
@@ -895,6 +904,8 @@ void OBS_API::openAllModules(void)
895904
896905 os_closedir (plugin_dir);
897906 }
907+
908+ return true ;
898909}
899910
900911double OBS_API::getCPU_Percentage (void )
0 commit comments