Only render async frames to texture once per frame

This prevents multiple needless calls to obs_source_get_frame and other
functions.  If the texture has already been processed, then just render
it as-is in any subsequent calls to obs_source_video_render.
This commit is contained in:
jp9000 2014-09-12 00:35:21 -07:00
parent 07c2d32a68
commit 52e08249f1
2 changed files with 15 additions and 8 deletions

View file

@ -293,6 +293,7 @@ struct obs_source {
uint64_t next_audio_ts_min;
uint64_t last_frame_ts;
uint64_t last_sys_timestamp;
bool async_rendered;
/* audio */
bool audio_failed;

View file

@ -503,6 +503,8 @@ void obs_source_video_tick(obs_source_t source, float seconds)
if (source->context.data && source->info.video_tick)
source->info.video_tick(source->context.data, seconds);
source->async_rendered = false;
}
/* unless the value is 3+ hours worth of frames, this won't overflow */
@ -1031,18 +1033,22 @@ static void obs_source_draw_async_texture(struct obs_source *source)
static void obs_source_render_async_video(obs_source_t source)
{
struct obs_source_frame *frame = obs_source_get_frame(source);
if (frame) {
if (!set_async_texture_size(source, frame))
return;
if (!update_async_texture(source, frame))
return;
if (!source->async_rendered) {
struct obs_source_frame *frame = obs_source_get_frame(source);
source->async_rendered = true;
if (frame) {
if (!set_async_texture_size(source, frame))
return;
if (!update_async_texture(source, frame))
return;
}
obs_source_release_frame(source, frame);
}
if (source->async_texture)
obs_source_draw_async_texture(source);
obs_source_release_frame(source, frame);
}
static inline void obs_source_render_filters(obs_source_t source)