瀏覽代碼

libobs: Add obs_reset_source_uuids

derrod 2 年之前
父節點
當前提交
1fd50a9324
共有 2 個文件被更改,包括 19 次插入0 次删除
  1. 15 0
      libobs/obs.c
  2. 4 0
      libobs/obs.h

+ 15 - 0
libobs/obs.c

@@ -2535,6 +2535,21 @@ obs_data_array_t *obs_save_sources(void)
 	return obs_save_sources_filtered(save_source_filter, NULL);
 }
 
+void obs_reset_source_uuids()
+{
+	pthread_mutex_lock(&obs->data.sources_mutex);
+
+	struct obs_source *source = obs->data.first_source;
+	while (source) {
+		bfree((void *)source->context.uuid);
+		source->context.uuid = os_generate_uuid();
+
+		source = (struct obs_source *)source->context.next;
+	}
+
+	pthread_mutex_unlock(&obs->data.sources_mutex);
+}
+
 /* ensures that names are never blank */
 static inline char *dup_name(const char *name, bool private)
 {

+ 4 - 0
libobs/obs.h

@@ -798,6 +798,10 @@ typedef bool (*obs_save_source_filter_cb)(void *data, obs_source_t *source);
 EXPORT obs_data_array_t *obs_save_sources_filtered(obs_save_source_filter_cb cb,
 						   void *data);
 
+/** Reset source UUIDs. NOTE: this function is only to be used by the UI and
+ *  will be removed in a future version! */
+EXPORT void obs_reset_source_uuids(void);
+
 enum obs_obj_type {
 	OBS_OBJ_TYPE_INVALID,
 	OBS_OBJ_TYPE_SOURCE,