Port::set_name doesn't work under PipeWire
Port::set_name doesn't work under PipeWire because https://gitlab.freedesktop.org/pipewire/pipewire-jack/-/blob/5965eda73356efa85c46a9119473a910860cbca4/src/pipewire-jack.c?page=4#L3126
SPA_EXPORT
int jack_port_set_name (jack_port_t *port, const char *port_name)
{
pw_log_warn("deprecated");
return 0;
}
Migrating to jack_port_rename would help, however, according to JACK documentation:
May NOT be called from a callback handling a server event.
New function! jack_port_rename
jack_port_rename isn't the in the bindings for jack_sys, so its probably relatively new. I probably need to make a cookbook for updated the bindings in a way that supports both dynamic_loading true/false and doesn't break any users.
If you want to load it dynamically at runtime:
- This is what happens when
dynamic_loadingfeature is enabled, which is by default. - https://docs.rs/jack-sys/latest/jack_sys/fn.library.html
- The underlying
jack_syspackage is re-exported asjack::jack_sys. - The type here is
unsafe extern "C" fn(*mut jack_port_t, *const ::libc::c_char) -> ::libc::c_int;
- The underlying
Calling Requirements
- I'm not sure if Rust has a way to guarantee this, will ask around, but best hacky ideas I have at the moment are either:
- Add
Port::renameas unsafe. - Create an object that marks the scope as being outside of callback handling.
- Mark its creation as unsafe.
- Add
I have locally changed Port::set_name implementation to use jack_port_rename and... the port was successfully renamed in pw-dump, but jack_lsp, qpwgraph and Carla were still showing the old name. So it looks like renaming ports in PipeWire doesn't work no matter which method is used.