Skip to content

fix(audio): bypass toggle no longer greys out after being turned off - #358

Merged
ajisth69 merged 1 commit into
Clash-Projects:mainfrom
xppenTC:fix/internal-direct-toggle
Oct 19, 2026
Merged

ajisth69 merged 1 commit into
Clash-Projects:mainfrom
xppenTC:fix/internal-direct-toggle

Conversation

@xppenTC

@xppenTC xppenTC commented Oct 19, 2026

Copy link
Copy Markdown
Contributor

Problem

In Settings, after turning Internal direct output off, the toggle often comes back greyed out and can only be switched on again after restarting the app (or changing the audio route).

Why: the toggle was enabled only while the current output was reported available. Turning the feature off closes the direct stream and re-evaluates the route from cached results:

  • a format Android mixed earlier (MIXED_BY_ANDROID for the whole route);
  • or an MMAP probe taken while our own stream still held the output (EXCLUSIVE_REFUSED).

Those caches were only cleared on a route change, hence the restart.

Fix

  • InternalDirectAvailability.canEnable: the toggle is locked only for permanent impossibilities (ANDROID_TOO_OLD, NATIVE_MISSING). Route- or format-specific results stay visible in the subtitle but no longer block re-enabling.
  • setWanted(true) clears mixedRoutes, openCache and cachedProbe, so re-enabling actually re-tests the output instead of replaying the old verdict.

Tests

  • InternalDirectSignalPathTest: new toggleStaysReachableUnlessTheDeviceCanNeverBypass test (18/18 tests pass on current main).
  • Reported on a real phone (toggle greyed after switching off). The fix has not been tested on the device yet.

🤖 Generated with Claude Code

https://claude.ai/code/session_01LR3s8LM4rGRXJiyve854EE

The "internal direct output" toggle was enabled only while the current
output was reported available. Turning it off closes the direct stream
and re-evaluates the route from cached results (a format Android mixed,
or a probe taken while our own stream held the output), so the toggle
often came back greyed out and could only be re-enabled after an app
restart or a route change.

- Lock the toggle only for permanent impossibilities (Android too old,
  native library missing); route/format-specific results stay shown in
  the subtitle but no longer block re-enabling.
- Re-enabling clears the mixed-format list, the open cache and the
  cached probe, so the output is actually tested again.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LR3s8LM4rGRXJiyve854EE
@ajisth69
ajisth69 merged commit 6761c95 into Clash-Projects:main Oct 19, 2026
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.

3 participants