diff --git a/openpilot/starpilot/soloist/bluealsa/README.md b/openpilot/starpilot/soloist/bluealsa/README.md index 755e5c65dd..e11fdfba4a 100644 --- a/openpilot/starpilot/soloist/bluealsa/README.md +++ b/openpilot/starpilot/soloist/bluealsa/README.md @@ -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 diff --git a/openpilot/starpilot/soloist/bluealsa/SHA256SUMS b/openpilot/starpilot/soloist/bluealsa/SHA256SUMS index f95775079f..b3e1479305 100644 --- a/openpilot/starpilot/soloist/bluealsa/SHA256SUMS +++ b/openpilot/starpilot/soloist/bluealsa/SHA256SUMS @@ -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 diff --git a/openpilot/starpilot/soloist/bluealsa/build.sh b/openpilot/starpilot/soloist/bluealsa/build.sh index 922ab04f49..d02db72513 100755 --- a/openpilot/starpilot/soloist/bluealsa/build.sh +++ b/openpilot/starpilot/soloist/bluealsa/build.sh @@ -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; } diff --git a/openpilot/starpilot/soloist/bluealsa/lib/libasound_module_pcm_bluealsa.so b/openpilot/starpilot/soloist/bluealsa/lib/libasound_module_pcm_bluealsa.so index 816c9dd8f3..d831e14dfd 100755 Binary files a/openpilot/starpilot/soloist/bluealsa/lib/libasound_module_pcm_bluealsa.so and b/openpilot/starpilot/soloist/bluealsa/lib/libasound_module_pcm_bluealsa.so differ diff --git a/openpilot/starpilot/soloist/bluealsa/patches/0001-pcm-poll-revents-unread-event.patch b/openpilot/starpilot/soloist/bluealsa/patches/0001-pcm-poll-revents-unread-event.patch new file mode 100644 index 0000000000..a155cf84e0 --- /dev/null +++ b/openpilot/starpilot/soloist/bluealsa/patches/0001-pcm-poll-revents-unread-event.patch @@ -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)