rust-jack icon indicating copy to clipboard operation
rust-jack copied to clipboard

Port::set_name doesn't work under PipeWire

Open teodly opened this issue 10 months ago • 2 comments

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.

teodly avatar Feb 28 '25 19:02 teodly

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_loading feature is enabled, which is by default.
  • https://docs.rs/jack-sys/latest/jack_sys/fn.library.html
    • The underlying jack_sys package is re-exported as jack::jack_sys.
    • The type here is unsafe extern "C" fn(*mut jack_port_t, *const ::libc::c_char) -> ::libc::c_int;

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::rename as unsafe.
    • Create an object that marks the scope as being outside of callback handling.
      • Mark its creation as unsafe.

wmedrano avatar Mar 05 '25 17:03 wmedrano

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.

teodly avatar Mar 19 '25 08:03 teodly