Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

libobs: Fix race when disconnecting raw video callbacks #11605

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

derrod
Copy link
Member

@derrod derrod commented Dec 8, 2024

Description

Ensures raw_active counter is only incremented/decremented if a callback was actually added/removed.

Motivation and Context

Fixes #11329

There is a race condition here where the encoder stopping due to failure will call remove_connection() from full_stop() and the output itself stopping will also call it from end_data_capture_thread(). This can result in the raw_active counter being decremented twice to -1, so that the next time an output is started the counter will be incremented to 0 (instead of 1), which is treated as inactive.

How Has This Been Tested?

Locally.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

  • My code has been run through clang-format.
  • I have read the contributing document.
  • My code is not on the master branch.
  • The code has been tested.
  • All commit messages are properly formatted and commits squashed where appropriate.
  • I have included updates to all appropriate documentation.

@derrod derrod added the Bug Fix Non-breaking change which fixes an issue label Dec 8, 2024
@DeeDeeG
Copy link

DeeDeeG commented Dec 10, 2024

The fix works for me, thanks!

(To be sure, I compiled OBS without this change (revision fbf2ea1) and could reproduce the original issue #11329. Recompiled with this PR (revision 6b0dd0b) and the issue is gone, no hangs. 👍)

(With this PR/fix, OBS can start new recordings successfully, and can exit cleanly, even after an encoder times out while using Hybrid MP4.)

@derrod derrod force-pushed the fix-disconnect-race branch from 6b0dd0b to f934902 Compare December 10, 2024 09:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Fix Non-breaking change which fixes an issue
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

If an encoder times out while using hybrid MP4, subsequent recordings hang/fail
3 participants