stream-labs / obs-studio-node

libOBS (OBS Studio) for Node.Js, Electron and similar tools
GNU General Public License v2.0
616 stars 99 forks source link

use remove source api #1297

Closed summeroff closed 1 year ago

summeroff commented 1 year ago

Description

Use obs_remove_source to have more control over a source deletion.

Motivation and Context

On a shutdown there is a few steps to make sure what resources get cleaned up. First FE call osn::Source::Release. Then destroyOBS_API release some objects. And then destroyOBS_API checks for sources what was not yet removed and call them for release. But there could be a race condition between releasing an source on prev step and checking for its existence on last. It could lead to a crash.

As a fix osn::Source::Release will use obs_source_remove and obs_source_removed to set object in removed state immediately mitigating a race condition.

This was not applied for a transition sources as they managed in a bit separate way. Release for them not expect them to be destroyed.

Also obs_set_output_source was moved to a begining of a sequence as sources can stay bind to output after an release.

How Has This Been Tested?

Run with additional logs to check cleanup of sources on a shutdown.

Types of changes

Checklist: