shared/bpm: Fixed crash when using Stream Delay #11291
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
While testing BPM in the Twitch Enhanced Broadcasting beta build an issue was uncovered where OBS Studio will crash due to an uninitialized mutex in the new BPM code. This crash only happens if:
With the official OBS Studio, the stream delay feature is not compatible with enhanced broadcasting and will be disabled if the streamer attempts to use stream delay, so there is currently no chance of running into this issue. However, once stream delay compatibility with enhanced broadcasting is upstreamed, the crash will occur in the case specified above, so best to eliminate it ahead of time.
The fix is very simple. Simply ensure the mutex is initialized once from either
bpm_inject()
orbpm_destroy()
, instead of relying onbpm_inject()
to always be called first.Motivation and Context
This is a bug fix for a very specific case that will cause OBS Studio to crash.
How Has This Been Tested?
Tested locally with the enhanced broadcasting beta build (Twitch Enhanced Broadcasting). It is very easy to reproduce and the fix works in all iterations I've tried.
Types of changes
Checklist: