Skip to content

fix: make mix_idx atomic#3

Merged
semnil merged 4 commits intomasterfrom
fix/atomic-mix-idx-and-plugin-support
Mar 26, 2026
Merged

fix: make mix_idx atomic#3
semnil merged 4 commits intomasterfrom
fix/atomic-mix-idx-and-plugin-support

Conversation

@semnil
Copy link
Owner

@semnil semnil commented Mar 26, 2026

  • Change mix_idx field to atomic_size_t to prevent data races between the audio thread (read) and UI thread (read-write)
  • Use atomic_load/atomic_store/atomic_init for all mix_idx accesses
  • Load mix_idx into a local var in mt2s_disconnect to avoid TOCTOU
  • Add null/bounds guard at the start of mt2s_connect
  • Cast literal 1 to size_t before shifting to avoid UB in bit-shift

@semnil semnil force-pushed the fix/atomic-mix-idx-and-plugin-support branch from 3a6be1a to fe1116c Compare March 26, 2026 02:33
@semnil semnil changed the title fix: make mix_idx atomic and fix snprintf buffer size in plugin-support fix: make mix_idx atomic Mar 26, 2026
semnil added 4 commits March 26, 2026 11:37
- Change mix_idx field to atomic_size_t to prevent data races between the audio thread (read) and UI thread (read-write)
- Use atomic_load/atomic_store/atomic_init for all mix_idx accesses
- Load mix_idx into a local var in mt2s_disconnect to avoid TOCTOU
- Add null/bounds guard at the start of mt2s_connect
- Cast literal 1 to size_t before shifting to avoid UB in bit-shift
…omic.h

Guard stdatomic.h with #ifndef _MSC_VER and provide an MSVC-compatible fallback using volatile size_t with inline wrapper functions.
This avoids requiring C11 mode in the OBS MSVC build config while maintaining source-level compatibility with atomic_init/load/store.
@semnil semnil force-pushed the fix/atomic-mix-idx-and-plugin-support branch from fe1116c to 1e894f6 Compare March 26, 2026 02:37
@semnil semnil merged commit db2ad87 into master Mar 26, 2026
6 checks passed
@semnil semnil deleted the fix/atomic-mix-idx-and-plugin-support branch March 26, 2026 02:49
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.

1 participant