Skip to content

Conversation

@sandboxcoder
Copy link

@sandboxcoder sandboxcoder commented Dec 8, 2025

Description

Relocating static variables into the instanced coreaudio struct that is passed into the thread to avoid a potential race condition? Granted, in this case, the variable seems to be initialized just fine so wasn't sure was this intended by the author? So not quite a 'bug'. Perhaps optional code cleanup

Motivation and Context

The input_callback function is invoked by the Apple audio thread. We were setting up static variables here which is shared between both coreaudio input/output threads. I am not sure if that is intended or not? But cannot hurt to relocate this into the thread's coreaudio struct?

How Has This Been Tested?

Verified in the debugger each thread has its' own factor and info variables.

Types of changes

  • Code cleanup (non-breaking change which makes code smaller or more readable)

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.
@sandboxcoder sandboxcoder changed the title Relocate static vars into coreaudio struct Dec 8, 2025
* This input_callback function is invoked by the Apple audio thread.
We are setting up a static var here which is shared between
both coreaudio input/output threads. I am not sure if that is intended or
not? But cannot hurt to relocate this into the thread's coreaudio struct?
@sandboxcoder sandboxcoder force-pushed the rno/mac-audio-callback-cleanup branch from dc7da80 to 8a7b6e0 Compare December 8, 2025 15:34
@WizardCM WizardCM added Code Cleanup Non-breaking change which makes code smaller or more readable macOS Affects macOS labels Dec 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Code Cleanup Non-breaking change which makes code smaller or more readable macOS Affects macOS

2 participants