Explorar o código

libobs: Call both get_defaults and get_defaults2

Unlike get_properties, there is not reason to not call get_defaults if it is
given in addition to get_defaults2. Additonally this fixes the bug with
'init_encoder' which would only ever call get_defaults, resulting in broken
encoders if those used get_defaults2.
Michael Fabian 'Xaymar' Dirks %!s(int64=6) %!d(string=hai) anos
pai
achega
3f6bbe2d49
Modificáronse 4 ficheiros con 19 adicións e 6 borrados
  1. 8 3
      libobs/obs-encoder.c
  2. 3 0
      libobs/obs-encoder.h
  3. 5 3
      libobs/obs-source.c
  4. 3 0
      libobs/obs-source.h

+ 8 - 3
libobs/obs-encoder.c

@@ -63,8 +63,12 @@ static bool init_encoder(struct obs_encoder *encoder, const char *name,
 	if (pthread_mutex_init(&encoder->outputs_mutex, NULL) != 0)
 		return false;
 
-	if (encoder->orig_info.get_defaults)
+	if (encoder->orig_info.get_defaults) {
 		encoder->orig_info.get_defaults(encoder->context.settings);
+	}
+	if (encoder->orig_info.get_defaults2) {
+		encoder->orig_info.get_defaults2(encoder->context.settings, encoder->orig_info.type_data);
+	}
 
 	return true;
 }
@@ -312,10 +316,11 @@ void obs_encoder_set_name(obs_encoder_t *encoder, const char *name)
 static inline obs_data_t *get_defaults(const struct obs_encoder_info *info)
 {
 	obs_data_t *settings = obs_data_create();
+	if (info->get_defaults) {
+		info->get_defaults(settings);
+	}
 	if (info->get_defaults2) {
 		info->get_defaults2(settings, info->type_data);
-	} else if (info->get_defaults) {
-		info->get_defaults(settings);
 	}
 	return settings;
 }

+ 3 - 0
libobs/obs-encoder.h

@@ -238,6 +238,9 @@ struct obs_encoder_info {
 
 	/**
 	 * Gets the default settings for this encoder
+	 * 
+	 * If get_defaults is also defined both will be called, and the first
+	 * call will be to get_defaults, then to get_defaults2.
 	 *
 	 * @param[out]  settings  Data to assign default settings to
 	 * @param[in]   typedata  Type Data

+ 5 - 3
libobs/obs-source.c

@@ -324,11 +324,13 @@ static obs_source_t *obs_source_create_internal(const char *id,
 		goto fail;
 
 	if (info) {
-		if (info->get_defaults2)
+		if (info->get_defaults) {
+			info->get_defaults(source->context.settings);
+		}
+		if (info->get_defaults2) {
 			info->get_defaults2(info->type_data,
 					    source->context.settings);
-		else if (info->get_defaults)
-			info->get_defaults(source->context.settings);
+		}
 	}
 
 	if (!obs_source_init(source))

+ 3 - 0
libobs/obs-source.h

@@ -441,6 +441,9 @@ struct obs_source_info {
 
 	/**
 	 * Gets the default settings for this source
+	 * 
+	 * If get_defaults is also defined both will be called, and the first
+	 * call will be to get_defaults, then to get_defaults2.
 	 *
 	 * @param       type_data The type_data variable of this structure
 	 * @param[out]  settings  Data to assign default settings to