m-default-nodes: wait properly for nodes and ports

Closed P V requested to merge pvir/wireplumber:default-nodes-fix into master

Device nodes and their ports may appear some time after devices. Deviceless nodes may also appear.

If m-default-nodes skipped re-evaluations because some node ports were not ready, it must retry when ports appear, because everything might be ready then.

Rescan also when potential sink/source candidate nodes are changed.

Fixes default nodes sometimes pointing to non-existent nodes.

The failure mode this fixes looks like this:

D 23:23:52.050591    m-default-nodes ../modules/module-default-nodes.c:448:nodes_ready: <WpDefaultNodes:0x621000019860> device 'bluez_card.00_1B_66_XX_XX_XX' is not ready (0/2)
D 23:23:52.050978    m-default-nodes ../modules/module-default-nodes.c:448:nodes_ready: <WpDefaultNodes:0x621000019860> device 'bluez_card.00_1B_66_XX_XX_XX' is not ready (0/2)
D 23:23:52.061262    m-default-nodes ../modules/module-default-nodes.c:448:nodes_ready: <WpDefaultNodes:0x621000019860> device 'bluez_card.00_1B_66_XX_XX_XX' is not ready (0/2)
D 23:23:52.061667    m-default-nodes ../modules/module-default-nodes.c:448:nodes_ready: <WpDefaultNodes:0x621000019860> device 'bluez_card.00_1B_66_XX_XX_XX' is not ready (0/2)
D 23:23:52.063633    m-default-nodes ../modules/module-default-nodes.c:448:nodes_ready: <WpDefaultNodes:0x621000019860> device 'bluez_card.00_1B_66_XX_XX_XX' is not ready (0/2)

and then the re-evaluation of defaults did not happen, even though the nodes appeared a bit later (and are visible to policy lua scripts, so you can play sound to them). Things start working again if e.g. default is changed manually, but it should not get stuck like this.

In theory, you'd expect the "objects-changed" signal would trigger a rescan, but it appears it is not fired always when new objects appear. There may be some problem in objectmanagers. grep "pending:" on trace-level log shows pending_objects apparently does not reach zero, so the objects-changed signal is blocked.

Testcase: pipewire master, meson test -C builddir test-functional with openal-info installed, and -Dsession-managers=wireplumber.

Edited by P V

Merge request reports