libobs: Prevent video cache clear on first frame

Fix a bug where when a source first starts up its async cache, it
unintentionally resets its cache, which means that the first few frames
would be lost.
master
jp9000 2015-03-07 08:45:12 -08:00
parent 2d5c6dfae9
commit ebee67097a
1 changed files with 7 additions and 1 deletions

View File

@ -196,6 +196,9 @@ obs_source_t *obs_source_create(enum obs_source_type type, const char *id,
source->flags = source->default_flags; source->flags = source->default_flags;
/* prevents the source from clearing the cache on the first frame */
source->async_reset_texture = true;
if (info && info->type == OBS_SOURCE_TYPE_TRANSITION) if (info && info->type == OBS_SOURCE_TYPE_TRANSITION)
os_atomic_inc_long(&obs->data.active_transitions); os_atomic_inc_long(&obs->data.active_transitions);
return source; return source;
@ -1474,11 +1477,14 @@ static inline struct obs_source_frame *cache_video(struct obs_source *source,
pthread_mutex_lock(&source->async_mutex); pthread_mutex_lock(&source->async_mutex);
if (async_texture_changed(source, frame)) { if (async_texture_changed(source, frame)) {
/* prevents the cache from being freed on the first frame */
if (!source->async_reset_texture)
free_async_cache(source);
source->async_width = frame->width; source->async_width = frame->width;
source->async_height = frame->height; source->async_height = frame->height;
source->async_format = frame->format; source->async_format = frame->format;
source->async_reset_texture = true; source->async_reset_texture = true;
free_async_cache(source);
} }
for (size_t i = 0; i < source->async_cache.num; i++) { for (size_t i = 0; i < source->async_cache.num; i++) {