Skip to content
Snippets Groups Projects
Commit 86d634ee authored by Jim's avatar Jim
Browse files

Check for valid sizes when initializing video

parent 778cc2b3
No related branches found
No related tags found
No related merge requests found
...@@ -1196,6 +1196,27 @@ void OBSBasic::SetService(obs_service_t newService) ...@@ -1196,6 +1196,27 @@ void OBSBasic::SetService(obs_service_t newService)
} }
} }
static inline int AttemptToResetVideo(struct obs_video_info *ovi)
{
int ret = obs_reset_video(ovi);
if (ret == OBS_VIDEO_INVALID_PARAM) {
struct obs_video_info new_params = *ovi;
if (new_params.window_width == 0)
new_params.window_width = 512;
if (new_params.window_height == 0)
new_params.window_height = 512;
new_params.output_width = new_params.window_width;
new_params.output_height = new_params.window_height;
new_params.base_width = new_params.window_width;
new_params.base_height = new_params.window_height;
ret = obs_reset_video(&new_params);
}
return ret;
}
int OBSBasic::ResetVideo() int OBSBasic::ResetVideo()
{ {
struct obs_video_info ovi; struct obs_video_info ovi;
...@@ -1225,7 +1246,7 @@ int OBSBasic::ResetVideo() ...@@ -1225,7 +1246,7 @@ int OBSBasic::ResetVideo()
ovi.window_width = size.width(); ovi.window_width = size.width();
ovi.window_height = size.height(); ovi.window_height = size.height();
ret = obs_reset_video(&ovi); ret = AttemptToResetVideo(&ovi);
if (ret == OBS_VIDEO_SUCCESS) if (ret == OBS_VIDEO_SUCCESS)
obs_add_draw_callback(OBSBasic::RenderMain, this); obs_add_draw_callback(OBSBasic::RenderMain, this);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment