0
0
mirror of https://github.com/obsproject/obs-studio.git synced 2024-09-20 13:08:50 +02:00

text-freetype2: Fix file reader occasionally not updating

This commit is contained in:
Skid-Inc 2017-06-27 11:15:00 +01:00
parent 2b085da63a
commit baebfd0ce8
3 changed files with 8 additions and 7 deletions

View File

@ -238,7 +238,7 @@ static void ft2_video_tick(void *data, float seconds)
time_t t = get_modified_timestamp(srcdata->text_file);
srcdata->last_checked = os_gettime_ns();
if (srcdata->m_timestamp != t) {
if (srcdata->update_file) {
if (srcdata->log_mode)
read_from_end(srcdata, srcdata->text_file);
else
@ -246,6 +246,12 @@ static void ft2_video_tick(void *data, float seconds)
srcdata->text_file);
cache_glyphs(srcdata, srcdata->text);
set_up_vertex_buffer(srcdata);
srcdata->update_file = false;
}
if (srcdata->m_timestamp != t) {
srcdata->m_timestamp = t;
srcdata->update_file = true;
}
}

View File

@ -38,6 +38,7 @@ struct ft2_source {
char *text_file;
wchar_t *text;
time_t m_timestamp;
bool update_file;
uint64_t last_checked;
uint32_t cx, cy, max_h, custom_width;

View File

@ -377,8 +377,6 @@ void load_text_from_file(struct ft2_source *srcdata, const char *filename)
srcdata->text = bzalloc(filesize);
bytes_read = fread(srcdata->text, filesize - 2, 1, tmp_file);
srcdata->m_timestamp =
get_modified_timestamp(srcdata->text_file);
bfree(tmp_read);
fclose(tmp_file);
@ -386,7 +384,6 @@ void load_text_from_file(struct ft2_source *srcdata, const char *filename)
}
fseek(tmp_file, 0, SEEK_SET);
srcdata->m_timestamp = get_modified_timestamp(srcdata->text_file);
tmp_read = bzalloc(filesize + 1);
bytes_read = fread(tmp_read, filesize, 1, tmp_file);
@ -464,8 +461,6 @@ void read_from_end(struct ft2_source *srcdata, const char *filename)
tmp_file);
remove_cr(srcdata->text);
srcdata->m_timestamp =
get_modified_timestamp(srcdata->text_file);
bfree(tmp_read);
fclose(tmp_file);
@ -485,7 +480,6 @@ void read_from_end(struct ft2_source *srcdata, const char *filename)
srcdata->text, (strlen(tmp_read) + 1));
remove_cr(srcdata->text);
srcdata->m_timestamp = get_modified_timestamp(srcdata->text_file);
bfree(tmp_read);
}