libobs: Add obs_scene_prune_sources

Adds a function that goes through the scene and releases all sources
that have been removed.
This commit is contained in:
gxalpha 2021-11-13 01:28:52 +01:00 committed by Jim
parent 9147ce3287
commit c104e59bd4
3 changed files with 22 additions and 0 deletions

View File

@ -265,6 +265,12 @@ General Scene Functions
---------------------
.. function:: void obs_scene_prune_sources(obs_scene_t *scene)
Releases all sources from a scene that have been marked as removed by obs_source_remove.
---------------------
.. _scene_item_reference:

View File

@ -3608,3 +3608,18 @@ obs_data_t *obs_sceneitem_transition_save(struct obs_scene_item *item,
: item->hide_transition_duration);
return data;
}
void obs_scene_prune_sources(obs_scene_t *scene)
{
DARRAY(struct obs_scene_item *) remove_items;
da_init(remove_items);
video_lock(scene);
update_transforms_and_prune_sources(scene, &remove_items.da, NULL);
video_unlock(scene);
for (size_t i = 0; i < remove_items.num; i++)
obs_sceneitem_release(remove_items.array[i]);
da_free(remove_items);
}

View File

@ -1821,6 +1821,7 @@ EXPORT void obs_sceneitem_transition_load(struct obs_scene_item *item,
obs_data_t *data, bool show);
EXPORT obs_data_t *obs_sceneitem_transition_save(struct obs_scene_item *item,
bool show);
EXPORT void obs_scene_prune_sources(obs_scene_t *scene);
/* ------------------------------------------------------------------------- */
/* Outputs */