Computing notes 2024 part two

This document contains only my personal opinions and calls of judgement, and where any comment is made as to the quality of anybody's work, the comment is an opinion, in my judgement.

[file this blog page at: dig del.icio.us Technorati]

2024 July

20240719 Fri: 'wireplumber' and Bluetooth

I have switched to Pipewire a while ago as it seems rather more efficient than PulseAudio and I have been fairly happy, even if its configuration is poorly documented and seems rather complicated.

To make the configuration easier PipeWire has two dynamic configuration systems called pipewire-media-session and wireplumber which is the new nicer thing that "dioscovers" audio devices and adds them to the PipeWire configuration, plus some graphical tools called Helvum and qpwgraph to adjust dynamically the audio flow graph.

wireplumber comes with a large set of Lua script to discover and configure devices (version 0.4 does, version 0.5 switched to JSON based configuration). The discovery process is done by monitor entities triggered by DBUS messages from various OS subsystems.

I have recently got a BlueTooth headset and every time I tried to connect to it I got two related error messages:

There are many, many web pages about this issue, but they never explain what is really going:

The error I got was that even if the headset BlueTooth connection worked, the BlueTooth daemon could not find a handler over DBUS for its type. The most common reason why that does not happen is that wireplumber does not have the relevant plugin that is in the libspa-0.2-bluetooth package (Debian/Ubuntu) but I had installed it so it ought to have worked, but then I discovered that the wireplumber BlueTooth did not invoke it. The reason is that /usr/share/wireplumber/scripts/monitors/bluez.lua and /usr/share/wireplumber/bluetooth.lua.d/30-bluez-monitor.lua (Debian/Ubuntu) have these lines:

  -- if logind support is enabled, activate
  -- the monitor only when the seat is active
  function startStopMonitor(seat_state)
    Log.info(logind_plugin, "Seat state changed: " .. seat_state)

    if seat_state == "active" then
      monitor = createMonitor()
    elseif monitor then
      monitor:deactivate(Feature.SpaDevice.ENABLED)
      monitor = nil
    end
  end
  if bluez_monitor.properties["with-logind"] then
    load_optional_module("logind")
  end

while I have systemd-logind installed I do not use it for X11 logins, so the "seat" seems inactive, and then wireplumber ignores BlueTooth devices. The relevant parameter is in /usr/share/wireplumber/bluetooth.lua.d/50-bluez-config.lua (Debian/Ubuntu):

  -- Enable the logind module, which arbitrates which user will be allowed
  -- to have bluetooth audio enabled at any given time (particularly useful
  -- if you are using GDM as a display manager, as the gdm user also launches
  -- pipewire and wireplumber).
  -- This requires access to the D-Bus user session; disable if you are running
  -- a system-wide instance of wireplumber.
  ["with-logind"] = true,

Setting it to false on my laptop allowed wireplumber to handle BlueTooth audio devices and thus the use of the headset, by putting in $XDG_CONFIG_DIR/wireplumber/bluetooth.lua.d/99-bluez-config.lua:

-- 'logind' is present but it is unused
bluez_monitor.properties = {
  ["with-logind"] = false,
}
sabi email