Bluetooth Audio add-on sets incomplete PulseAudio device name, causing Kodi fallback to ALSA and audio interruptions

  • 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 microSD

    Software

    LibreELEC version: 12.2.1
    Bluetooth Audio add-on: service.bluetooth-audio v12.2.0.1
    PulseAudio version shown by pactl info: 17.0

    Problem summary

    When using Bluetooth audio through LibreELEC/Kodi, the Bluetooth connection is established correctly and PulseAudio creates the expected Bluetooth sink, for example:

    Code
    bluez_sink.70_99_1C_D5_6C_A7.a2dp_sink

    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:

    Code
    PULSE:Default

    instead of the full PulseAudio device value recognized by Kodi:

    Code
    PULSE:Default|Bluetooth Audio (PULSEAUDIO)

    Steps to reproduce

    1. Boot LibreELEC on Raspberry Pi 4.
    2. Connect a Bluetooth audio device using LibreELEC Bluetooth configuration.
    3. Start Kodi and play an audio file, especially MP3.
    4. Open Kodi audio settings.
    5. In some cases Kodi shows ALSA as the selected output device.
    6. Playback may stop or become unstable.
    7. 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:

    Code
    Default Sink: bluez_sink.70_99_1C_D5_6C_A7.a2dp_sink
    bluez_sink... SUSPENDED

    Kodi log also showed that the Bluetooth Audio add-on was setting the device to the incomplete value:

    Code
    service.bluetooth-audio: setting default audio device "PULSE:Default" on start

    When the audio output was manually changed from the Kodi GUI to PulseAudio, the correct value was written:

    Code
    <setting id="audiooutput.audiodevice">PULSE:Default|Bluetooth Audio (PULSEAUDIO)</setting>

    and PulseAudio showed an active Kodi stream:

    Code
    application.name = "KodiSink"
    media.name = "kodi audio stream"
    Sink: bluez_sink...

    Expected behavior

    The Bluetooth Audio add-on should set Kodi’s audio output device to the full PulseAudio device string used by Kodi:

    Code
    PULSE:Default|Bluetooth Audio (PULSEAUDIO)

    instead of:

    Code
    PULSE:Default

    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:

    Code
    /storage/.kodi/addons/service.bluetooth-audio/default.py

    The problematic line was found here:

    Code
    self.pulsedevice = 'PULSE:Default'

    The add-on data file also contained the incomplete value:

    Code
    /storage/.kodi/userdata/addon_data/service.bluetooth-audio/settings.xml

    with:

    Code
    <setting id="audiodevice">PULSE:Default</setting>

    Workaround / local patch

    Changing the add-on code from:

    Code
    self.pulsedevice = 'PULSE:Default'

    to:

    Code
    self.pulsedevice = 'PULSE:Default|Bluetooth Audio (PULSEAUDIO)'

    and updating:

    Code
    <setting id="audiodevice">PULSE:Default|Bluetooth Audio (PULSEAUDIO)</setting>

    in:

    Code
    /storage/.kodi/userdata/addon_data/service.bluetooth-audio/settings.xml

    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:

    Code
    service.bluetooth-audio: setting default audio device "PULSE:Default|Bluetooth Audio (PULSEAUDIO)" on start
    PulseAudio: Opened device Default in pcm mode

    Additional logs and outputs

    I can provide a full debug log if needed.

    Relevant commands used during testing:

    Code
    pactl 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
    lsusb

    Suggested fix

    Please consider updating service.bluetooth-audio so that it stores and applies the full Kodi PulseAudio device identifier:

    Code
    PULSE:Default|Bluetooth Audio (PULSEAUDIO)

    instead of the shorter/incomplete value:

    Code
    PULSE:Default

    or alternatively dynamically retrieve the exact PulseAudio device identifier from Kodi’s enumerated audio devices before applying the setting.