Posts by alex.caserini
-
-
If you've investigated the problem and already figured out the fix/solution, perhaps send us a pull request?
Yes, I can try to prepare a pull request.
I have already identified and tested a minimal local fix on my LibreELEC 12.2.1 / Raspberry Pi 4 setup. The issue seems to be in service.bluetooth-audio: it sets Kodi’s audio output device to the incomplete value:
while Kodi works correctly when the full validated PulseAudio device id is used:
After patching default.py locally and updating the add-on setting, Bluetooth audio now works correctly after reboot and auto-connect, and Kodi shows PulseAudio correctly instead of falling back to ALSA.
Before I open a PR, could you please confirm which source repository and branch I should target for service.bluetooth-audio?
On my installed system the affected file is:
but I would like to make sure I submit the fix against the correct upstream source tree.
Sorry I'm not a developer
-
Hello,
I would like to report a reproducible Bluetooth audio issue on LibreELEC/Kodi.
Hardware
Device: Raspberry Pi 4
GPU: Broadcom VideoCore VI / Raspberry Pi 4 integrated GPU
Bluetooth audio device used for testing: JBL GO 2
Original target device: car Bluetooth audio/head unit
Storage: USB SSD used only as media storage; system boots from microSDSoftware
LibreELEC version: 12.2.1
Bluetooth Audio add-on: service.bluetooth-audio v12.2.0.1
PulseAudio version shown by pactl info: 17.0Problem summary
When using Bluetooth audio through LibreELEC/Kodi, the Bluetooth connection is established correctly and PulseAudio creates the expected Bluetooth sink, for example:
However, Kodi sometimes shows ALSA as the active audio output device, and MP3 playback has audio interruptions or can stop when entering the audio settings screen.
The issue appears to be caused by the service.bluetooth-audio add-on setting Kodi’s audio output device to the incomplete value:
instead of the full PulseAudio device value recognized by Kodi:
Steps to reproduce
- Boot LibreELEC on Raspberry Pi 4.
- Connect a Bluetooth audio device using LibreELEC Bluetooth configuration.
- Start Kodi and play an audio file, especially MP3.
- Open Kodi audio settings.
- In some cases Kodi shows ALSA as the selected output device.
- Playback may stop or become unstable.
- Manually changing the audio output in Kodi from ALSA to PulseAudio immediately restores correct audio playback.
Observed behavior
Before the workaround, Kodi could end up with this setting in guisettings.xml:
Code<setting id="audiooutput.audiodevice">ALSA:@|Default (vc4-hdmi-0 MAI PCM i2s-hifi-0) ()</setting>At the same time, PulseAudio still had the Bluetooth sink available, but it was suspended and there was no active Kodi stream:
Kodi log also showed that the Bluetooth Audio add-on was setting the device to the incomplete value:
When the audio output was manually changed from the Kodi GUI to PulseAudio, the correct value was written:
and PulseAudio showed an active Kodi stream:
Expected behavior
The Bluetooth Audio add-on should set Kodi’s audio output device to the full PulseAudio device string used by Kodi:
instead of:
Kodi should consistently show PulseAudio as the selected audio output device after Bluetooth auto-connect, and audio playback should not fall back to ALSA or stop when entering the audio settings screen.
Investigation
The relevant add-on file is:
The problematic line was found here:
The add-on data file also contained the incomplete value:
with:
Workaround / local patch
Changing the add-on code from:
to:
and updating:
in:
fixed the problem.
After reboot:
- Bluetooth connects automatically.
- Kodi shows PulseAudio correctly in the audio settings page.
- guisettings.xml keeps the correct value.
- PulseAudio sink is active.
- Audio playback works normally.
- The previous ALSA fallback no longer occurs.
Kodi log after the patch shows:
Codeservice.bluetooth-audio: setting default audio device "PULSE:Default|Bluetooth Audio (PULSEAUDIO)" on start PulseAudio: Opened device Default in pcm modeAdditional logs and outputs
I can provide a full debug log if needed.
Relevant commands used during testing:
Codepactl info pactl list sinks short pactl list sink-inputs grep -iE 'audiooutput.audiodevice|audiooutput.passthrough' /storage/.kodi/userdata/guisettings.xml grep -iE 'service.bluetooth-audio|PulseAudio|OpenSink|ALSA|PULSE' /storage/.kodi/temp/kodi.log dmesg lsusbSuggested fix
Please consider updating service.bluetooth-audio so that it stores and applies the full Kodi PulseAudio device identifier:
instead of the shorter/incomplete value:
or alternatively dynamically retrieve the exact PulseAudio device identifier from Kodi’s enumerated audio devices before applying the setting.
-
Below is the "production-grade" procedure from scratch, which radically eliminates the ordering cycle error on LibreELEC.
The principle is simple: kodi-avrcp must never be directly linked to kodi.service, kodi.target, or graphical.target.
In production, it is started via a systemd post-boot timer.Production Installation (LibreELEC) – anti-ordering-cycle version
1) Prerequisites on LibreELEC
Enable SSH (if needed): LibreELEC Settings → Services → SSH ON
Enable Kodi JSON-RPC via HTTP: Kodi Settings → Services → Control
Allow remote control via HTTP: ON
Port: 8080Quick verification (from LibreELEC):
curl -s -u kodi:kodi -X POST -H 'Content-Type: application/json' \
--data '{"jsonrpc":"2.0","method":"JSONRPC.Ping","id":1}' \
http://127.0.0.1:8080/jsonrpc
Expected: pong.2) Compile on PC (Ubuntu) for the correct architecture
On LibreELEC:
uname -m
If it is armv7l:CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=7 \
go build -trimpath -ldflags="-s -w" -o kodi-avrcp
If it is aarch64:CGO_ENABLED=0 GOOS=linux GOARCH=arm64 \
go build -trimpath -ldflags="-s -w" -o kodi-avrcp
Check:file ./kodi-avrcp
2.2) Copy to LibreELEC
scp ./kodi-avrcp root@IPLIBREELEC:/storage/.config/kodi-avrcp
On LibreELEC:chmod +x /storage/.config/kodi-avrcp
ls -l /storage/.config/kodi-avrcp3) "Root" cleanup (removes links that generate cycles)
On LibreELEC:
# Stop/disable any old versions
systemctl disable --now kodi-avrcp.service 2>/dev/null
true
systemctl disable --now kodi-avrcp.timer 2>/dev/null
true
systemctl reset-failed kodi-avrcp.service 2>/dev/null
true# (Optional but recommended) if kodi-autostart creates cycles, disable it
systemctl disable --now kodi-autostart.service 2>/dev/null
true
systemctl reset-failed kodi-autostart.service 2>/dev/null
[cite_start]true [cite: 8]# Remove any old units in /storage/.config/system.d
rm -f /storage/.config/system.d/kodi-avrcp.service
rm -f /storage/.config/system.d/kodi-avrcp.timer
If you created drop-ins for kodi in the past (rare but possible), check:ls -l /storage/.config/system.d/kodi.service.d 2>/dev/null
true
If files exist there that mention kodi-avrcp/kodi-autostart, delete them.4) Create the kodi-avrcp.service (without Kodi/graphical.target)
On LibreELEC:
mkdir -p /storage/.config/system.d
cat > /storage/.config/system.d/kodi-avrcp.service <<'EOF'
[Unit]
Description=Kodi AVRCP metadata bridge (Kodi JSON-RPC -> BlueZ RegisterPlayer)
After=bluetooth.service
Wants=bluetooth.service[Service]
Type=simple
# Delay to allow time for BT and Kodi to be ready, without direct dependencies
ExecStartPre=/bin/sh -c 'sleep 12'
ExecStart=/storage/.config/kodi-avrcp
Restart=always
RestartSec=2Environment=KODI_URL=http://127.0.0.1:8080/jsonrpc
Environment=KODI_USER=kodi
Environment=KODI_PASS=kodi
Environment=BLUEZ_ADAPTER=hci0
# (optional) Environment=POLL_MS=900EOF
Note: the [Install] WantedBy=... section is intentionally missing here.
5) Create and enable the timer (post-boot start)
This is the point that eliminates the cycle.cat > /storage/.config/system.d/kodi-avrcp.timer <<'EOF'
[Unit]
Description=Start kodi-avrcp after boot (avoid ordering cycles)[Timer]
OnBootSec=25
Unit=kodi-avrcp.service[Install]
WantedBy=timers.target
EOFActivate:
systemctl daemon-reload
systemctl enable --now kodi-avrcp.timer
systemctl status kodi-avrcp.timer -l --no-pager6) Immediate test (without rebooting)
Manual start:
systemctl start kodi-avrcp.service
systemctl status kodi-avrcp.service -l --no-pager
journalctl -u kodi-avrcp.service -n 60 --no-pager
Expected: a line like “Registered MPRIS player …”. -
HI,
I've solved the problem....
someone need the solution?Ciao!
-
-
Is LE or the head-unit the playback device? (where is media read, what is controlling playback) .. What's the OS/capabilities of the (factory, aftermarket?) head unit in the car?
Hi,
The situation is:
First: usb SSD --> LE rpi4 usb --> Bluetooth dongle ---> (only audio) --->car entrainment
Second: internet --> android phone --> Bluetooth --> car entrainment
in both situation car entrainment is like a Bluetooth speaker.
but.. if I use a android phone on the car display I can se: Title, artist, cover, remaining time, etc... (now playng information)
I like to see all information even with LE.
TNKS
-
Hi,
nobody can help me?
Tnks
-
Hi all,
now I've a mobile media center with 1 Rpi4, 2 SSD (and another nerd option..
).RPI actual is connected to my car entertainment system by Bluetooth...
I'm looking a way to see "now playing" information on car display (like a connection with my android phone)
there is a solution with LE (or another tricks?)
TNKs in advance...
Ciao
Alex
-
Hi,
tnks for the answer... but..
I've spent a lot of time on google...
Just for undertand if i found a right information on the net...
1) Pulse audio, support metadata information.
2) the chain is Kodi --> Pulseaudio --> my receiver
So the problem is: kodi don't send metadata to pulse audio, right?
ther in no way to do this? (add on, trik...?)
tnks in advance
-
Nobody may help me?
Tnks In adv!
-
Please change the title to reflect your issue. "RPI 4 Bluetooth" is too generic.
Done!
-
Hi,
I've made a mobile mediacenter with RPI4.
The audio is sent to my car stereo by bluetooth.
From this point of view it's ok.
But, if I stream from my android phone i can see on radio display all information about file (title, author and picture)
From RPI not working (i can skip ff & rw only), there is a way for do this?
tnks in advance
Alex