Link Factory fails despite nodes existing
Version, Distribution, Desktop Environment:
pipewire
Compiled with libpipewire 0.3.31
Linked with libpipewire 0.3.31
Arch Linux, KDE 5.22.2
Description of Problem:
The changelog of 0.3.26 states that:
The link factory can now also make links between nodes and ports by name so that it can be used in scripts.
However I can't seem to get the link-factory to create a link between two nodes.
How Reproducible:
Always
Steps to Reproduce:
pw_properties *props = pa_properties_new(nullptr, nullptr);
pw_properties_set(props, PW_KEY_APP_NAME, "soundux");
pw_properties_set(props, PW_KEY_LINK_INPUT_NODE, std::to_string(in).c_str());
pw_properties_set(props, PW_KEY_LINK_OUTPUT_NODE, std::to_string(out).c_str());
auto *proxy = reinterpret_cast<pw_proxy *>(pw_core_create_object(core, "link-factory", PW_TYPE_INTERFACE_Link, PW_VERSION_LINK, &props->dict, 0));
In this example:
in
is equal to 101
out
is equal to 102
I also tried to do the same with different nodes how ever that fails too, also pw-cli
is also not able to create such a link successfully.
Also passing the node's names instead of their id does also not work.
When looking at the module-link-factory source code I could see the following:
struct find_node find = {
.id = atoi(name),
.name = name,
};
if (find.id != 0) {
struct pw_global *global = pw_context_find_global(context, find.id);
if (global != NULL && pw_global_is_type(global, PW_TYPE_INTERFACE_Node))
return pw_global_get_object(global);
}
When I try to execute pw_context_find_global
on the node ids of the two given nodes I get the following (most likely due to the fact that the nodes were already processed by onGlobalAdded):
auto *node1 = pw_context_find_global(context, in);
auto *node2 = pw_context_find_global(context, out);
// node1 and node2 are both a nullptr;
How ever pw-cli info <nodeId>
seems to work, pw-cli does not retrieve the node through pw_context_find_global
but instead maintains it's own node list
Something that may be interesting to note is that the link-factory only fails to find the input swapping the input and output still results in the input not being found, this may be interesting because the input node is obtained after the output node, as seen here
Info about the two nodes
pipewire-0>>info 101
id: 101
permissions: rwxm
type: PipeWire:Interface:Node/3
* input ports: 2/64
* output ports: 2/0
* state: "running"
* properties:
* media.class = "Audio/Sink"
* node.name = "soundux_sink"
* factory.name = "support.null-audio-sink"
* factory.id = "18"
* client.id = "124"
* node.driver = "true"
* factory.mode = "merge"
* audio.adapt.follower = ""
* library.name = "audioconvert/libspa-audioconvert"
* object.id = "101"
* params: (7)
* 3 (Spa:Enum:ParamId:EnumFormat) r-
* 1 (Spa:Enum:ParamId:PropInfo) r-
* 2 (Spa:Enum:ParamId:Props) rw
* 4 (Spa:Enum:ParamId:Format) rw
* 10 (Spa:Enum:ParamId:EnumPortConfig) r-
* 11 (Spa:Enum:ParamId:PortConfig) rw
* 0 (Spa:Enum:ParamId:Invalid) --
pipewire-0>>info 102
id: 102
permissions: rwxm
type: PipeWire:Interface:Node/3
* input ports: 2/64
* output ports: 2/0
* state: "running"
* properties:
* client.api = "pipewire-pulse"
* pulse.server.type = "unix"
* application.name = "WEBRTC VoiceEngine"
* application.process.id = "249577"
* application.process.user = "curve"
* application.process.host = "curve-arch"
* application.process.binary = "DiscordCanary"
* application.language = "en_US.UTF-8"
* window.x11.display = ":0"
* application.process.machine-id = "4a2080efbcb24c18aea62504bc32c5e0"
* application.process.session-id = "2"
* media.name = "recStream"
* stream.is-live = "true"
* node.name = "WEBRTC VoiceEngine"
* node.autoconnect = "true"
* media.class = "Stream/Input/Audio"
* adapt.follower.node = ""
* factory.id = "6"
* audio.adapt.follower = ""
* factory.mode = "merge"
* library.name = "audioconvert/libspa-audioconvert"
* object.id = "102"
* client.id = "78"
* node.latency = "1440/48000"
* pulse.attr.maxlength = "4194304"
* pulse.attr.fragsize = "5760"
* params: (7)
* 3 (Spa:Enum:ParamId:EnumFormat) r-
* 1 (Spa:Enum:ParamId:PropInfo) r-
* 2 (Spa:Enum:ParamId:Props) rw
* 4 (Spa:Enum:ParamId:Format) rw
* 10 (Spa:Enum:ParamId:EnumPortConfig) r-
* 11 (Spa:Enum:ParamId:PortConfig) rw
* 0 (Spa:Enum:ParamId:Invalid) rw
Expected Results:
The two nodes are linked
Actual Results:
The link factory reports the following error:
"link-factory: unknown input port (null)"