Skip to content

Use the PULSE_SERVER env var to locate the pulseaudio socket#229

Open
Tulon wants to merge 1 commit into
AsahiLinux:mainfrom
Tulon:Tulon/use-PULSE_SERVER-env-var-to-locate-PA-socket
Open

Use the PULSE_SERVER env var to locate the pulseaudio socket#229
Tulon wants to merge 1 commit into
AsahiLinux:mainfrom
Tulon:Tulon/use-PULSE_SERVER-env-var-to-locate-PA-socket

Conversation

@Tulon
Copy link
Copy Markdown

@Tulon Tulon commented Jun 5, 2026

This change makes sound in muvm work in a Snap sandbox. The commit message explains exactly what the patch does and why it's necessary.

I've been applying this patch to muvm that I ship as part of the arm64 Snap build of Wine Bar for a month or two already - seems to work well.

Just keep in mind I don't really know Rust - the code is not necessarily the most optimal or elegant.

Also, I haven't tested it with the latest version of muvm. I currently ship muvm-0.5.1 as part of WineBar.

Comment thread crates/muvm/src/bin/muvm.rs Outdated
Comment thread crates/muvm/src/bin/muvm.rs Outdated
Comment thread crates/muvm/src/bin/muvm.rs Outdated
.context("XDR_RUNTIME_DIR should not contain null characters")
.ok()
} else {
eprintln!(
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this needed?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I was debugging the issue of having no sound in muvm running in a Snap sandbox, there were no useful diagnostic messages as far as I remember. I decided to add some, just in case.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, but you can return a Result here, and only do the error print if both of them fail

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could, but then the error message would have less context. The way it's done now, not only does it tell you that the PA socket is missing but it also tells you where it got the path from.

Note that this won't be a spurious warning, as this function is called only as a last resort.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still think that it should return a Result, for example your .context calls are useless, as the .ok immediately discards the error message.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've made it return Result<CString> though now the call site is way complex than before. Someone who doesn't know Rust really shouldn't be making such complex refactorings.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The second helper also has the same issue

Comment thread crates/muvm/src/bin/muvm.rs Outdated
Comment thread crates/muvm/src/bin/muvm.rs Outdated
@Tulon Tulon force-pushed the Tulon/use-PULSE_SERVER-env-var-to-locate-PA-socket branch 4 times, most recently from d1bacc0 to 0166db4 Compare June 6, 2026 09:29
Comment thread crates/muvm/src/bin/muvm.rs Outdated
@Tulon Tulon force-pushed the Tulon/use-PULSE_SERVER-env-var-to-locate-PA-socket branch from 0166db4 to a197aea Compare June 6, 2026 09:41
If it's missing, fall back to appending "pulse/native" to
XDG_RUNTIME_DIR.

The thing is, when running in a Snap confined environment,
XDG_RUNTIME_DIR will be something like this:

    /run/user/<UID>/snap.<SNAP_NAME>

while PULSE_SERVER will be:

    unix:/run/user/<UID>/snap.<SNAP_NAME>/../pulse/native

Because apps expect XDG_RUNTIME_DIR to be writable and the
Snap runtime doesn't want Snaps polluting the system
XDG_RUNTIME_DIR, it mounts `/run/user/<UID>` as read-only
but then mounts a read-write `snap.<SNAP_NAME>` subdirectory
under it, setting XDG_RUNTIME_DIR to that writable subdirectory.

Signed-off-by: Joseph Artsimovich <joseph.artsimovich@gmx.com>
@Tulon Tulon force-pushed the Tulon/use-PULSE_SERVER-env-var-to-locate-PA-socket branch from a197aea to 9772276 Compare June 6, 2026 10:19
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.

2 participants