Skip to content

Commit

Permalink
add refresh interval
Browse files Browse the repository at this point in the history
  • Loading branch information
exeldro committed May 6, 2020
1 parent d4796ff commit 92ec165
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 9 deletions.
3 changes: 2 additions & 1 deletion data/locale/en-US.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ Freeze="Freeze"
FreezeFilter="Freeze Filter"
FreezeEnable="Enable Freeze"
FreezeDisable="Disable Freeze"
Duration="Duration (0 for indefinite)"
Duration="Duration (0 for indefinite)"
RefreshInterval="Refresh Interval (0 for no refresh)"
20 changes: 16 additions & 4 deletions freeze-filter.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ struct freeze_info {
bool processed_frame;
obs_hotkey_pair_id hotkey;
float duration;
uint64_t duration_max;
uint32_t duration_max;
uint32_t refresh_interval;
float last_refresh;
};

static const char *freeze_get_name(void *type_data)
Expand Down Expand Up @@ -78,9 +80,8 @@ static void freeze_update(void *data, obs_data_t *settings)
{
struct freeze_info *freeze = data;
freeze->duration_max = obs_data_get_int(settings, "duration");
freeze->cx = 0;
freeze->cy = 0;
free_textures(freeze);
freeze->refresh_interval =
obs_data_get_int(settings, "refresh_interval");
}

static void draw_frame(struct freeze_info *f)
Expand Down Expand Up @@ -151,6 +152,10 @@ static obs_properties_t *freeze_properties(void *data)
obs_property_t *p = obs_properties_add_int(
ppts, "duration", obs_module_text("Duration"), 0, 100000, 1000);
obs_property_int_set_suffix(p, "ms");
p = obs_properties_add_int(ppts, "refresh_interval",
obs_module_text("RefreshInterval"), 0,
100000, 1000);
obs_property_int_set_suffix(p, "ms");
return ppts;
}

Expand Down Expand Up @@ -192,10 +197,17 @@ static void freeze_tick(void *data, float t)
f->duration += t;
if (f->duration_max && f->duration * 1000.0 > f->duration_max) {
obs_source_set_enabled(f->source, false);
} else if (f->refresh_interval &&
f->duration > f->last_refresh &&
(f->duration - f->last_refresh) * 1000.0 >=
f->refresh_interval) {
f->processed_frame = false;
f->last_refresh = f->duration;
}
} else {
f->processed_frame = false;
f->duration = 0.0f;
f->last_refresh = 0.0f;
}
if (f->hotkey == OBS_INVALID_HOTKEY_PAIR_ID) {
obs_source_t *parent = obs_filter_get_parent(f->source);
Expand Down
8 changes: 4 additions & 4 deletions freeze-filter.rc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
1 VERSIONINFO
FILEVERSION 0,0,1,0
PRODUCTVERSION 0,0,1,0
FILEVERSION 0,0,2,0
PRODUCTVERSION 0,0,2,0
FILEFLAGSMASK 0x0L
#ifdef _DEBUG
FILEFLAGS 0x1L
Expand All @@ -17,12 +17,12 @@ BEGIN
BEGIN
VALUE "CompanyName", "Exeldro"
VALUE "FileDescription", "Freeze Filter"
VALUE "FileVersion", "0.0.1"
VALUE "FileVersion", "0.0.2"
VALUE "InternalName", "freeze-filter"
VALUE "LegalCopyright", "(C) Exeldro"
VALUE "OriginalFilename", "freeze-filter"
VALUE "ProductName", "Freeze Filter"
VALUE "ProductVersion", "0.0.1"
VALUE "ProductVersion", "0.0.2"
END
END
BLOCK "VarFileInfo"
Expand Down

0 comments on commit 92ec165

Please sign in to comment.