Skip to content

Check preview output instead of is_running to prevent leaks#1377

Merged
Trouffman merged 7 commits into
DistroAV:masterfrom
BitRate27:audiothreadleak
Feb 17, 2026
Merged

Check preview output instead of is_running to prevent leaks#1377
Trouffman merged 7 commits into
DistroAV:masterfrom
BitRate27:audiothreadleak

Conversation

@BitRate27

Copy link
Copy Markdown
Contributor

This fixes #1335 by checking for the existence of preview output instead of is_running. The is_running check was causing a leak of the audio thread.

This can be duplicated by launching an OBS and turning on preview output in DistroAV Output Settings. In another OBS, also turn on Preview Output with the same NDI name as the first OBS. This does not create a sender because one already exists with the same name. When the second OBS Preview Output, which was not created, is turned off, it doesn't close the preview output because it is not actually running. The output was created, it just wasn't running.

The fix is to check if the output exists instead of checking if it is running.

@Trouffman

Copy link
Copy Markdown
Collaborator

Should we update this on the main_output ?

Should we revise the is_running for this purpose everywhere too?

@BitRate27

Copy link
Copy Markdown
Contributor Author

When I did this I verified the issue did not exist on Main. However, for the sake of consistency, I went ahead and dug into the differences between starting and stopping main and preview output and found that preview did not report the error and stop the output if it was not able to create the ndi output when the name was already used (by another instance of OBS). So I added code to stop the preview output if it was not created. I also checked context.output instead of context.is_running when stopping main output.

FYI: Filter output does not use the obs_output pipeline, no audio thread started, so nothing to do in that part of the code.

@BitRate27 BitRate27 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have confirmed the audio thread does not leak when creating preview output with the same name as and existing output (ie. main). Also added the code recommended in the issue discussion to bdupstr the ndi_name for OBS voi and aoi info as suggested in the original issue. This is just to be correct and not cause any doubt when finding issues with output from DistroAV.

@BitRate27 BitRate27 self-assigned this Feb 15, 2026
@BitRate27
BitRate27 requested a review from Trouffman February 15, 2026 10:48
@Trouffman
Trouffman merged commit ad522f9 into DistroAV:master Feb 17, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: audio_thread created by ndi-6.1.1 is not closed during exiting

2 participants