module-rt: error out on load if no bus is available
Since the recent changes to the RT module in Pipewire 0.3.75, some applications such as those using OpenAL-Soft will crash on startup if neither the session nor the system bus is available. For example:
bwrap --dev-bind / / \
--bind /dev/null /run/dbus/system_bus_socket \
--bind /dev/null $XDG_RUNTIME_DIR/bus \
openal-info
Will result in a crash with the following error message:
dbus[1626147]: arguments to dbus_message_new_method_call() were incorrect, assertion "path != NULL" failed in file dbus-message.c line 1373.
This is normally a bug in some application using the D-Bus library.
The RT module previously failed to load if no bus was available, but after the recent changes, the init. logic runs in a thread, and failing to obtain the bus no longer causes the module to fail to load.
Then, functions called later such as pw_rtkit_make_realtime
assume the bus is available and try to use it, causing the error above.
Put the logic for obtaining and checking the bus back to module_init
, so the module fails to load again if no bus is available.