浏览代码

libobs: Improve module register warnings

Fixes some typos and specifies the function that's being called
jp9000 9 年之前
父节点
当前提交
2a4ac3dc21
共有 1 个文件被更改,包括 17 次插入8 次删除
  1. 17 8
      libobs/obs-module.c

+ 17 - 8
libobs/obs-module.c

@@ -523,6 +523,15 @@ cleanup:
 			info->free_type_data(info->type_data);            \
 	} while (false)
 
+#define source_warn(format, ...) \
+	blog(LOG_WARNING, "obs_register_source: " format, ##__VA_ARGS__)
+#define output_warn(format, ...) \
+	blog(LOG_WARNING, "obs_register_output: " format, ##__VA_ARGS__)
+#define encoder_warn(format, ...) \
+	blog(LOG_WARNING, "obs_register_encoder: " format, ##__VA_ARGS__)
+#define service_warn(format, ...) \
+	blog(LOG_WARNING, "obs_register_service: " format, ##__VA_ARGS__)
+
 void obs_register_source_s(const struct obs_source_info *info, size_t size)
 {
 	struct obs_source_info data = {0};
@@ -535,13 +544,13 @@ void obs_register_source_s(const struct obs_source_info *info, size_t size)
 	} else if (info->type == OBS_SOURCE_TYPE_TRANSITION) {
 		array = &obs->transition_types.da;
 	} else if (info->type != OBS_SOURCE_TYPE_SCENE) {
-		blog(LOG_ERROR, "Tried to register unknown source type: %u",
+		source_warn("Tried to register unknown source type: %u",
 				info->type);
 		goto error;
 	}
 
 	if (get_source_info(info->id)) {
-		blog(LOG_WARNING, "Source d '%s' already exists!  "
+		source_warn("Source '%s' already exists!  "
 		                  "Duplicate library?", info->id);
 		goto error;
 	}
@@ -559,12 +568,12 @@ void obs_register_source_s(const struct obs_source_info *info, size_t size)
 
 	if ((data.output_flags & OBS_SOURCE_COMPOSITE) != 0) {
 		if ((data.output_flags & OBS_SOURCE_AUDIO) != 0) {
-			blog(LOG_WARNING, "Source '%s': Composite sources "
+			source_warn("Source '%s': Composite sources "
 					"cannot be audio sources", info->id);
 			goto error;
 		}
 		if ((data.output_flags & OBS_SOURCE_ASYNC) != 0) {
-			blog(LOG_WARNING, "Source '%s': Composite sources "
+			source_warn("Source '%s': Composite sources "
 					"cannot be async sources", info->id);
 			goto error;
 		}
@@ -589,7 +598,7 @@ void obs_register_source_s(const struct obs_source_info *info, size_t size)
 #undef CHECK_REQUIRED_VAL_
 
 	if (size > sizeof(data)) {
-		blog(LOG_ERROR, "Tried to register obs_source_info with size "
+		source_warn("Tried to register obs_source_info with size "
 				"%llu which is more than libobs currently "
 				"supports (%llu)", (long long unsigned)size,
 				(long long unsigned)sizeof(data));
@@ -608,7 +617,7 @@ error:
 void obs_register_output_s(const struct obs_output_info *info, size_t size)
 {
 	if (find_output(info->id)) {
-		blog(LOG_WARNING, "Output id '%s' already exists!  "
+		output_warn("Output id '%s' already exists!  "
 		                  "Duplicate library?", info->id);
 		goto error;
 	}
@@ -644,7 +653,7 @@ error:
 void obs_register_encoder_s(const struct obs_encoder_info *info, size_t size)
 {
 	if (find_encoder(info->id)) {
-		blog(LOG_WARNING, "Encoder id '%s' already exists!  "
+		encoder_warn("Encoder id '%s' already exists!  "
 		                  "Duplicate library?", info->id);
 		goto error;
 	}
@@ -670,7 +679,7 @@ error:
 void obs_register_service_s(const struct obs_service_info *info, size_t size)
 {
 	if (find_service(info->id)) {
-		blog(LOG_WARNING, "Service id '%s' already exists!  "
+		service_warn("Service id '%s' already exists!  "
 		                  "Duplicate library?", info->id);
 		goto error;
 	}