fix(bt): don't idle-disconnect while audio is playing to the controller - #146
Open
gunCannoli wants to merge 1 commit into
Open
fix(bt): don't idle-disconnect while audio is playing to the controller#146gunCannoli wants to merge 1 commit into
gunCannoli wants to merge 1 commit into
Conversation
Idle Disconnect drops the controller after its timeout based only on the absence of meaningful HID input. Using the controller as a headset -- a headset in its 3.5 mm jack, watching a movie -- means no button input for long stretches, so the controller idle-disconnects mid-playback and the audio cuts out. Treat audio actively routed to the controller as the device being in use. audio_output_route_protected() (audio_recent() || usb_speaker_streaming_active()) already exists in bt.cpp and is already used for the RSSI idle gate and output-route protection, so this reuses it rather than adding a new signal. The idle clock is reset rather than simply returning, so the full timeout restarts when playback stops -- matching how a button press resets it. Returning without the reset would leave a long playback session about to trip the timeout the moment audio ends. Placement mirrors the existing mute[1] mic-mute carve-out: after it, before the timeout comparison. No new state, no companion command, no protocol change, no UI change. The RSSI-idle source assertion in usb_descriptor_migration_test.cpp is extended to require the guard, its exact body, and its ordering between the mic-mute carve-out and the timeout comparison. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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.
Problem
Idle Disconnect drops the controller after its timeout based only on the
absence of meaningful HID input. Audio playback is not considered.
Using the controller as a headset -- a headset plugged into the 3.5 mm jack,
watching a movie or listening to music -- means no button input for long
stretches. The controller idle-disconnects mid-playback and the audio cuts
out. The only workarounds are disabling Idle Disconnect or setting an
impractically long timeout.
Change
One condition in
src/bt.cpp, in the inactivity check inl2cap_packet_handler_cold():audio_output_route_protected()(audio_recent() || usb_speaker_streaming_active())already exists in the same file and is already used for the RSSI idle gate
and output-route protection. This reuses it rather than adding a new signal.
The idle clock is reset (rather than simply returning) so the full timeout
restarts when playback stops -- matching how a button press resets it.
Returning without the reset would leave a long playback session about to trip
the timeout the moment audio ends.
Placement is after the existing
mute[1]mic-mute carve-out and before thetimeout comparison. It mirrors that carve-out in location and shape.
Scope
COMMAND_ID, noPROTOCOL_MINORbump.selector behave exactly as before; they simply stop firing during
playback.
check.
Testing
tests/firmware/usb_descriptor_migration_test.cpp-- the RSSI-idle sourceassertion is extended to require the new guard, its exact body, and its
ordering between the mic-mute carve-out and the timeout comparison. All
firmware host-side suites pass.
Hardware (Waveshare RP2350B-Plus-W, Idle Disconnect set to 1 minute):
connected well past the timeout, audio uninterrupted.
after audio stopped, not immediately.
before.