Skip to content

Conversation

@valpackett
Copy link
Contributor

@valpackett valpackett commented Nov 7, 2025

Looks like at some point, PipeWire swapped around the order of the attached fds, so audio playback has been broken here. As a hotfix, follow the change. [..]

The message payload contains indexes for the attached file descriptors.
We must use them instead of relying on the order, which was never guaranteed,
and actually differs in practice between architectures in compilers
because current PipeWire code calls the fd-attaching function inside of
function call arguments, which don't have a defined evaluation order
in the C language standard.

@slp
Copy link
Collaborator

slp commented Nov 14, 2025

I've just gave this a try on Fedora Asahi 43, and I can confirm works fine as-is, without this PR. I think we need to know why is actually switching places...

@valpackett
Copy link
Contributor Author

Oh, I see: https://gitlab.freedesktop.org/pipewire/pipewire/-/blob/18ff08243bc2819d0f4e09f9a8fec6a6ef7a9767/src/modules/module-client-node/protocol-native.c#L685

	spa_pod_builder_add_struct(b,
			       SPA_POD_Fd(pw_protocol_native_add_resource_fd(resource, readfd)),
			       SPA_POD_Fd(pw_protocol_native_add_resource_fd(resource, writefd)),
			       SPA_POD_Int(mem_id),
			       SPA_POD_Int(offset),
			       SPA_POD_Int(size));

The order of evaluation of call args in C is unspecified, so it just happens to have the opposite order between targets and/or compilers. The protocol does not rely on it, they can be added in any order, the index is returned and written into the struct.

@valpackett valpackett changed the title muvm-guest: pwbridge: swap eventfd directions to fix playback muvm-guest: pwbridge: actually read fd indexes in the Transport msg [fix pipewire on x86_64] Nov 20, 2025
@valpackett valpackett marked this pull request as ready for review November 20, 2025 04:30
@valpackett
Copy link
Contributor Author

Added actual message parsing now \o/ This should work everywhere.

The message payload contains indexes for the attached file descriptors.
We must use them instead of relying on the order, which was never guaranteed,
and *actually* differs in practice between architectures in compilers
because current PipeWire code calls the fd-attaching function inside of
function call arguments, which *don't* have a defined evaluation order
in the C language standard.

Signed-off-by: Val Packett <[email protected]>
@valpackett
Copy link
Contributor Author

friendly ping for another (hopefully final) review :)

@slp slp merged commit f00a4ee into AsahiLinux:main Dec 2, 2025
2 checks passed
@valpackett valpackett deleted the val/kwootowwltmt branch December 2, 2025 18:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants