fix: connect A2DP after pairing and enable JustWorksRepairing for BT headsets#730
Open
carroarmato0 wants to merge 5 commits into
Open
fix: connect A2DP after pairing and enable JustWorksRepairing for BT headsets#730carroarmato0 wants to merge 5 commits into
carroarmato0 wants to merge 5 commits into
Conversation
…dsets The XRadio BT controller firmware generates link keys with store_hint=0, meaning BlueZ never persists the key to disk. This caused two symptoms: 1. Earbuds disconnect ~2s after pairing: after the BR/EDR bond completes, nothing initiates the A2DP audio profile connection. The earbuds time out waiting for the host to open the audio channel and disconnect (reason 2 = remote terminated). Fixed by calling `bluetoothctl connect` immediately after `bluetoothctl pair` in PLAT_bluetoothPair(). 2. No sound after sleep/wake (fixes LoveRetro#467): bt_init.sh stop/start clears the controller's volatile key memory. On wake, earbuds try to reconnect but BlueZ rejects them (no stored key, JustWorksRepairing=never default). Fixed by patching main.conf to set JustWorksRepairing=always before bluetoothd starts, allowing earbuds to re-initiate the bond from their side without user interaction. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
tg5050 (TrimUI Smart Pro S) uses an AIC8800 BT chip, not XRadio. Remove the chip-specific attribution from the comment so it accurately describes the symptom rather than incorrectly referencing XRadio. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
When earbuds power off abruptly, BlueZ may have already cleared the device's service cache by the time audiomon processes the disconnect signal. The previous hasUUID() call on disconnect would return false in that race, silently skipping the audio switch-back to the internal speaker. Fix by caching the connected A2DP device MAC at connect time and comparing against it on disconnect, avoiding the BlueZ query entirely. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…witch ALSA caches its PCM configuration. After BT disconnects and .asoundrc is deleted, setting AUDIODEV=default still resolves through the cached config which may still point to bluealsa — causing SDL to open a dead PCM and producing no or garbled audio from the speaker. Fix by naming both endpoints explicitly, matching the same pattern already used for BT (bluealsa): - Speaker: plughw:0 (card 0, with format/rate conversion) - USB DAC: plughw:1 (card 1, with format/rate conversion) - Bluetooth: bluealsa (unchanged) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
frysee
reviewed
May 19, 2026
| // .asoundrc is deleted. Name both endpoints explicitly to bypass the cache. | ||
| if (device == AUDIO_SINK_BLUETOOTH) | ||
| SDL_setenv("AUDIODEV", "bluealsa", 1); | ||
| else if (device == AUDIO_SINK_USBDAC) |
Member
There was a problem hiding this comment.
We cant rely on that order. Example:
- USB-C device connected on boot, might enumerate as card 0
- As a result, internal speaker comes up as card 1 (even after disconnecting the usb device).
… audio switch" This reverts commit f1a7932.
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.
Summary
PLAT_bluetoothPair()now callsbluetoothctl connectafterbluetoothctl pairso the A2DP audio profile is opened immediately after bonding. Without this, earbuds time out (~2 s) waiting for the host to initiate the audio channel and disconnect themselves (BlueZreason 2 = remote terminated).bt_init.shnow setsJustWorksRepairing = alwaysinmain.confbefore startingbluetoothd. The XRadio BT controller firmware generates link keys withstore_hint=0, so BlueZ never persists the key to disk. After a sleep/wake cycle the key is gone; withJustWorksRepairing=never(the BlueZ default) earbuds can't reconnect without the user re-pairing manually. Setting it toalwayslets the earbuds re-initiate the bond from their side on wake.Fixes #467 (no sound after sleep when using BT headphones).
Root cause
The XRadio chip used in TrimUI devices sets
store_hint=0in the MGMTNEW_LINK_KEYevent. BlueZ respects this flag and skips writing[LinkKey]to the device info file, so the device is never consideredPaired=true. This means:Files changed
workspace/all/common/generic_bt.cbluetoothctl connectafterbluetoothctl pairinPLAT_bluetoothPair()skeleton/SYSTEM/tg5040/etc/bluetooth/bt_init.shmain.conftoJustWorksRepairing=alwaysbefore bluetoothd startsskeleton/SYSTEM/tg5050/etc/bluetooth/bt_init.shI've tested this using my Raycon Earbuds and seems to work reliably. Before this fix the earbuds would simply not connect (or get disconnected immediately)