image-source: Don't check for changes when hidden

If an image source isn't visible there is no point polling for changes
during the time it's hidden as no one will see them. Should the image
be on unreachable media such as an unavailable network share, this
check would cause the graphics thread to periodically stall trying to
detect changes of a non-visible image source.

If the image is modified while it's hidden, the updated file will now
be loaded as soon as the source is made visible - the update timer
intentionally ticks up while hidden.

Partially fixes some of the behavior described in
https://github.com/obsproject/obs-studio/issues/3007, a full fix
likely requires significant changes to support OS-specific file change
notification APIs.
This commit is contained in:
Richard Stanway 2020-06-01 22:32:23 +02:00
parent 72a94cb6f5
commit 4ec875485d

View File

@ -160,12 +160,14 @@ static void image_source_tick(void *data, float seconds)
context->update_time_elapsed += seconds;
if (context->update_time_elapsed >= 1.0f) {
time_t t = get_modified_timestamp(context->file);
context->update_time_elapsed = 0.0f;
if (obs_source_showing(context->source)) {
if (context->update_time_elapsed >= 1.0f) {
time_t t = get_modified_timestamp(context->file);
context->update_time_elapsed = 0.0f;
if (context->file_timestamp != t) {
image_source_load(context);
if (context->file_timestamp != t) {
image_source_load(context);
}
}
}