Repository navigation
Conversation
The secondary IO callback can read `.crossfading` in updateProgress just before the main thread runs complete(), then store progress = 1.0 after the reset (totalSamples is now 0). Once the secondary is promoted to primary, nothing clears progress while idle, and the idle branch of primaryMultiplier returned 0 for progress >= 1.0. The app kept playing and the meter kept moving, but its output stayed silent until the tap was rebuilt. The idle guard had no remaining job: before promotion the phase is `.crossfading` (cos -> 0), and after promotion the old primary callback has a stale callbackID and writes zeros. Idle now always returns 1.0. Refs ronitsingh10#461 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
temporaryna
added a commit
to temporaryna/FineTune
that referenced
this pull request
Nov 12, 2026
Port of upstream PR ronitsingh10#487 (fixes ronitsingh10#461). A secondary IO callback reading .crossfading just before complete() can store progress = 1.0 after the reset; nothing clears it while idle, and the idle branch of primaryMultiplier returned 0 for progress >= 1.0 — the promoted tap stayed muted until rebuilt. Idle now always returns 1.0: before promotion the phase is .crossfading, so the cosine curve already takes the old primary to ~0, and post-promotion stale-role callbacks are zeroed by the role guard in processAudioCallback. Observed live: after the monitor unplug, every device switch forced through '[CROSSFADE] Timeout at 0.000000%' — apps ended with dead taps (one app's audio bypassing the tap raw, another consumed silently).
RobinLandy
added a commit
to RobinLandy/FineTune
that referenced
this pull request
Nov 16, 2026
Keep a lock-free gain target and give each IOProc its own ramp. Route the popup, media keys and HUD through the master setting. Order switch cleanup, guard reconnect promotion and preserve input preference and persisted levels. The initial master-volume DSP was adapted from wait2050/FineTune-Sync (GPLv3), be99199. The targeted reconnect and idle crossfade fixes follow upstream FineTune PRs ronitsingh10#314 (clem-git) and ronitsingh10#487 (NicoM701).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes the race described in #461: after a device switch, an app can keep playing (and its meter keeps moving) while FineTune outputs silence until the tap gets rebuilt.
CrossfadeState.updateProgressruns on the secondary IO callback. If that callback reads.crossfadingjust before the main thread runspromoteSecondaryToPrimary()+complete(), it can storeprogress = 1.0after the reset (totalSamplesis 0 by then). The phase is idle, nothing clearsprogresswhile idle, and the idle branch ofprimaryMultiplierreturned 0 forprogress >= 1.0. The promoted tap, now the primary, stays muted.The fix makes the idle branch always return 1.0. The old guard had no job left to do. Before promotion the phase is
.crossfading, so the cosine curve already takes the old primary to ~0. Callbacks from the old primary that enter after promotion have a stale callbackID, so the role guard inprocessAudioCallbackzeros their output. An already-running callback retains its role and can finish a buffer at unity gain after the reset; that was already possible whencomplete()reset progress to 0, and this change does not introduce it.complete()already resetprogressto 0 on every non-racy path. The change adds no work on the audio thread.I replaced the existing idle test, which asserted the old behavior, with a regression test for the stale-progress state.
Proof: a standalone two-thread harness compiled against the real
CrossfadeState.swift. It models the secondary callback (role check, peak scan,updateProgress) racing the promotion andcomplete(). Onmainit left the promoted tap silent in 40 to 125 of every 100k promotions, red in 5 of 5 runs. With this change it was 0 in 5 of 5 runs, even though the stale idleprogress = 1.0state still occurred 11 to 77 times per run. The new test fails onmainand all 25CrossfadeStatetests pass with the fix.xcodebuild build-for-testing(Debug) succeeds. I did not run the fullxcodebuild testlocally, because the test host launches the full app next to my installed FineTune.This fixes the race in #461. I can't show it was the cause of every silent-output report there. The other changes in the patch attached to #461 (health-check eligibility, destructive-switch volume restore) are not part of this PR.
Reviewed with sol-loop: 2 independent reviews with gpt-6.1-sol. Sol verdict: approved. The second review clarified the in-flight callback limitation above; no further code changes were needed.
Created with Claude Opus 5.5 in Claude Code.
🤖 Generated with Claude Code