mirror of
https://github.com/obsproject/obs-studio.git
synced 2026-09-24 23:31:36 +08:00
(API Change) obs_reset_video: Use return codes
Changed API functions: libobs: obs_reset_video Before, video initialization returned a boolean, but "failed" is too little information, if it fails due to lack of device capabilities or bad video device parameters, the front-end needs to know that. The OBS Basic UI has also been updated to reflect this API change.
This commit is contained in:
@@ -513,11 +513,25 @@ void OBSBasic::OBSInit()
|
||||
throw "Failed to initialize libobs";
|
||||
if (!InitBasicConfig())
|
||||
throw "Failed to load basic.ini";
|
||||
if (!ResetVideo())
|
||||
throw "Failed to initialize video";
|
||||
if (!ResetAudio())
|
||||
throw "Failed to initialize audio";
|
||||
|
||||
int ret = ResetVideo();
|
||||
|
||||
switch (ret) {
|
||||
case OBS_VIDEO_MODULE_NOT_FOUND:
|
||||
throw "Failed to initialize video: Graphics module not found";
|
||||
case OBS_VIDEO_NOT_SUPPORTED:
|
||||
throw "Failed to initialize video: Your graphics adapter "
|
||||
"is either too old or does not have the required "
|
||||
"capabilities required for this program";
|
||||
case OBS_VIDEO_INVALID_PARAM:
|
||||
throw "Failed to initialize video: Invalid parameters";
|
||||
default:
|
||||
if (ret != OBS_VIDEO_SUCCESS)
|
||||
throw "Failed to initialize video: Unspecified error";
|
||||
}
|
||||
|
||||
InitOBSCallbacks();
|
||||
|
||||
/* TODO: this is a test, all modules will be searched for and loaded
|
||||
@@ -1182,9 +1196,10 @@ void OBSBasic::SetService(obs_service_t newService)
|
||||
}
|
||||
}
|
||||
|
||||
bool OBSBasic::ResetVideo()
|
||||
int OBSBasic::ResetVideo()
|
||||
{
|
||||
struct obs_video_info ovi;
|
||||
int ret;
|
||||
|
||||
GetConfigFPS(ovi.fps_num, ovi.fps_den);
|
||||
|
||||
@@ -1210,11 +1225,11 @@ bool OBSBasic::ResetVideo()
|
||||
ovi.window_width = size.width();
|
||||
ovi.window_height = size.height();
|
||||
|
||||
if (!obs_reset_video(&ovi))
|
||||
return false;
|
||||
ret = obs_reset_video(&ovi);
|
||||
if (ret == OBS_VIDEO_SUCCESS)
|
||||
obs_add_draw_callback(OBSBasic::RenderMain, this);
|
||||
|
||||
obs_add_draw_callback(OBSBasic::RenderMain, this);
|
||||
return true;
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool OBSBasic::ResetAudio()
|
||||
|
||||
Reference in New Issue
Block a user