openpilot
openpilot copied to clipboard
micd: fix thread safety by adding locking for shared state
Fixes multiple threading issues in micd by adding a lock to protect shared state accessed by both the audio callback and the main update loop.
All reads and writes to shared variables are now guarded by this lock, this prevents race conditions and ensures consistent, correct operation when the callback and update methods are called from different threads.