Bluetooth Fix

Fix random car-audio dropouts: the BlueALSA ALSA plugin tested an
uninitialised value for its "disconnected" marker, so it falsely
dropped the Bluetooth output every few minutes. Rebuilt plugin with
patches/0001; see the patch for details.
This commit is contained in:
whoisdomi
2026-11-14 19:24:12 -06:00
parent 42670a1e27
commit 2ffc883a6f
5 changed files with 32 additions and 4 deletions
@@ -1,7 +1,8 @@
# Bundled BlueALSA 5.0.0
Linux/ARM64 binaries and matching PCM/CTL plugins come from upstream commit
`1935d6dcb8975f2d7a51aaafe61538d157224623`, without decoder patches. Keep `bin/`,
`1935d6dcb8975f2d7a51aaafe61538d157224623`, without decoder patches. `build.sh`
applies `patches/*.patch`; each patch file states what it fixes. Keep `bin/`,
`lib/`, version, source revision, checksums and license files together. Activation
validates checksums, ELF architecture and executable permissions.
@@ -37,7 +38,10 @@ openpilot/starpilot/soloist/bluealsa/build.sh /tmp/bluealsa-5
```
Setup downloads dependencies; the build exports the pinned upstream commit and
runs offline. `BUILD_IMAGE` and `BUILD_PACKAGES.txt` record inputs; apt package
runs offline. `lib/libasound_module_pcm_bluealsa.so` was rebuilt alone with patch 0001 under
x86 ARM64 emulation, where the upstream suite cannot run reliably; the other
artifacts and the recorded test results are from the unpatched build.
`BUILD_IMAGE` and `BUILD_PACKAGES.txt` record inputs; apt package
availability is not pinned. `UPSTREAM_TEST_RESULTS.txt` records 19 passing programs.
Local integration tests cover integrity, configuration, activation failure and
old-checkout recovery with simulated service calls. They do not establish audible
@@ -2,4 +2,4 @@ bcb5e1a1a8462a5aaaf1fa198b09c9fb9bd26cb8d658b052462a0336655cf7b7 bin/bluealsa-a
e9d30ca988de2856d4bc98e1b1b2b81a461fe021c008fd15ccaf0faa9925c128 bin/bluealsactl
60c91e60d36b55d670e886170539e4ee7223d2f2153fafafe8e570cbf2b18672 bin/bluealsad
d1cf683fe82ff1f3c7268fe2614ada5a05a63e3ceb2603689c08740b5618f118 lib/libasound_module_ctl_bluealsa.so
3372f48574b56b320424ee8e3f9319aa920967d16538c6ff77f3ac94174b19c4 lib/libasound_module_pcm_bluealsa.so
4db221633e3d480be97cfec40d361b6b659fece7a00849592b2c07425dfa3586 lib/libasound_module_pcm_bluealsa.so
@@ -14,7 +14,7 @@ if [[ $# != 1 || ! -d $1/.git ]]; then
fi
source_dir=$(cd "$1" && pwd)
[[ $(git -C "$source_dir" rev-parse HEAD) == "$source_commit" ]] || { echo 'Wrong BlueALSA source revision' >&2; exit 1; }
# Export only committed upstream files. Local changes are never silently bundled.
# Export only committed upstream files plus the reviewed patches in patches/. Local changes are never silently bundled.
mkdir -p build
archive=$(mktemp)
trap 'rm -f "$archive"' EXIT
@@ -25,6 +25,7 @@ docker run --rm --platform linux/arm64 --pull never --network none \
mkdir /tmp/source
cd /tmp/source
tar xf /package/build/upstream.tar
for patch in /package/patches/*.patch; do git apply "$patch"; done
autoreconf --install >/tmp/autoreconf.log 2>&1 || { cat /tmp/autoreconf.log; exit 1; }
./configure --localstatedir=/data/starpilot/bluealsa5 --disable-debug --disable-manpages --enable-ldac --enable-ofono --enable-test --with-libsamplerate > /tmp/configure.log 2>&1 || { cat /tmp/configure.log; exit 1; }
make -j4 >/tmp/make.log 2>&1 || { cat /tmp/make.log; exit 1; }
@@ -0,0 +1,23 @@
pcm: do not test an unread event value in poll_revents
Under PulseAudio 16.1 (module-alsa-sink, tsched=0) bluealsa_poll_revents() is
entered with POLLIN set while the eventfd is already drained, about 11 times a
minute on a comma 3X. eventfd_read() then fails with EAGAIN and the
uninitialised value was tested for the 0xDEAD0000 marker, so stack garbage made
the plugin report the PCM as disconnected (-ENODEV) every few minutes while
audio was flowing. Measured on device: 8 false disconnects in 20 minutes
before, 0 in 12 minutes with 142 failed reads after.
diff --git a/src/asound/bluealsa-pcm.c b/src/asound/bluealsa-pcm.c
index 3aee1cb..daa944d 100644
--- a/src/asound/bluealsa-pcm.c
+++ b/src/asound/bluealsa-pcm.c
@@ -1377,7 +1377,7 @@ static int bluealsa_poll_revents(snd_pcm_ioplug_t *io, struct pollfd *pfd,
if (pfd[0].revents & POLLIN) {
- eventfd_t event;
+ eventfd_t event = 0;
eventfd_read(pcm->event_fd, &event);
if (event & 0xDEAD0000)