Explorar o código

text-freetype2: Avoid spamming the log

When polling the file for changes, if the file doesn't exist, avoid
repeating the message over and over again that it couldn't find the
file.
jp9000 %!s(int64=11) %!d(string=hai) anos
pai
achega
d95d20aa46

+ 1 - 0
plugins/text-freetype2/text-freetype2.c

@@ -318,6 +318,7 @@ static void ft2_source_update(void *data, obs_data_t settings)
 	    srcdata->from_file != from_file)
 		vbuf_needs_update = true;
 
+	srcdata->file_load_failed = false;
 	srcdata->from_file = from_file;
 
 	if (srcdata->font_name != NULL) {

+ 1 - 0
plugins/text-freetype2/text-freetype2.h

@@ -33,6 +33,7 @@ struct ft2_source {
 	uint16_t font_size;
 	uint32_t font_flags;
 
+	bool file_load_failed;
 	bool from_file;
 	char *text_file;
 	wchar_t *text;

+ 8 - 2
plugins/text-freetype2/text-functionality.c

@@ -314,7 +314,10 @@ void load_text_from_file(struct ft2_source *srcdata, const char *filename)
 
 	tmp_file = fopen(filename, "rb");
 	if (tmp_file == NULL) {
-		blog(LOG_WARNING, "Failed to open file %s", filename);
+		if (!srcdata->file_load_failed) {
+			blog(LOG_WARNING, "Failed to open file %s", filename);
+			srcdata->file_load_failed = true;
+		}
 		return;
 	}
 	fseek(tmp_file, 0, SEEK_END);
@@ -368,7 +371,10 @@ void read_from_end(struct ft2_source *srcdata, const char *filename)
 
 	tmp_file = fopen(filename, "rb");
 	if (tmp_file == NULL) {
-		blog(LOG_WARNING, "Failed to open file %s", filename);
+		if (!srcdata->file_load_failed) {
+			blog(LOG_WARNING, "Failed to open file %s", filename);
+			srcdata->file_load_failed = true;
+		}
 		return;
 	}
 	fread(&value, 2, 1, tmp_file);