Jelajahi Sumber

libobs: Fix bug where outputs cannot initialize hotkeys

When an output's context data is being created, it cannot register any
hotkeys because the output has not initialized its reference counting
capability.  This is due to the fact that when a hotkey is registered,
it creates a weak reference to the source/output/service/encoder.

The solution to this is to make sure the output's reference counter data
is created before calling the create callback.
jp9000 9 tahun lalu
induk
melakukan
ec4317dd2b
1 mengubah file dengan 6 tambahan dan 6 penghapusan
  1. 6 6
      libobs/obs-output.c

+ 6 - 6
libobs/obs-output.c

@@ -129,12 +129,6 @@ obs_output_t *obs_output_create(const char *id, const char *name,
 	if (ret < 0)
 		goto fail;
 
-	if (info)
-		output->context.data = info->create(output->context.settings,
-				output);
-	if (!output->context.data)
-		blog(LOG_ERROR, "Failed to create output '%s'!", name);
-
 	output->reconnect_retry_sec = 2;
 	output->reconnect_retry_max = 20;
 	output->valid               = true;
@@ -146,6 +140,12 @@ obs_output_t *obs_output_create(const char *id, const char *name,
 			&obs->data.outputs_mutex,
 			&obs->data.first_output);
 
+	if (info)
+		output->context.data = info->create(output->context.settings,
+				output);
+	if (!output->context.data)
+		blog(LOG_ERROR, "Failed to create output '%s'!", name);
+
 	blog(LOG_DEBUG, "output '%s' (%s) created", name, id);
 	return output;