Skip to content

Conversation

austinleroy
Copy link
Contributor

Hello again! While tinkering, I was able to fix a couple of issues I saw and thought it might be helpful to push these adjustments upstream. For reference, I'm working on getting mmclient set up and running on my Steam Deck OLED.

My first commit (fixing cursor lock) stops an issue I was seeing where the client would frequently crash. Winit wasn't able to lock the cursor on this device, and so any application that tried to do so would cause the client to abort. I feel like this fix is safe - it won't affect anything that was already working, and confining the cursor seemed to work just as well from my test cases.

My second commit (changing the audio buffer size) is a little more invasive, and I'm honestly not 100% sure why it fixed the issue I was seeing. The issue it fixes is this: on my Steam Deck, when running an application, audio was delayed by about 1-2 seconds and was extremely static-y/poppy sounding (video and input seemed to be just fine, only audio had the problem). Research led me to believe this could be caused by audio buffer size, so that's where I started investigating. The sample_rate coming in was 48000, and so the buffer size was being set to 480 (which seems reasonable). On a whim, I tried hardcoding the value to 512, and, like magic, the problem went away. I looked around and found a mention of powers of 2 being better for some Linux audio functions, but nothing concrete (this seems to be specific to JACK - https://wiki.linuxaudio.org/wiki/list_of_jack_frame_period_settings_ideal_for_usb_interface). Testing this change on other clients didn't seem to introduce any issues (audio still worked fine), so I figured I'd roll with it.

Feel free to take one or both (or none) of these changes - just figured I would put them up here to try and help anyone else who might face similar issues.

@colinmarc
Copy link
Owner

Weird that locking the cursor doesn't work on the steam deck. Could you send me a WAYLAND_DEBUG=1 log? Maybe I just need to update winit or something.

@colinmarc
Copy link
Owner

For the audio thing, would you be willing to try pointing at my cpal PR (RustAudio/cpal#957) and seeing if that fixes the audio issues? Make sure you enable the pulseaudio feature.

@austinleroy
Copy link
Contributor Author

austinleroy commented Oct 3, 2025

Sure, no trouble!

For clarity, I added the following to Cargo.toml inside mm-client and ran everything off the current main branch (commit hash: 3c61f28)

[patch.crates-io.cpal]
git = "https://github.com/colinmarc/cpal"
rev = "86aae4edbf0c4600048038d42e8a56edad8b4e9c"
features = ["pulseaudio"]

Unfortunately, the audio still behaved exactly the same with that patch (delayed by seconds, lots of pops). I can see if I can upload a video from my phone if that would help.

I ran the client with "WAYLAND_DEBUG=1", but it doesn't seem to give any additional output - was I supposed to run something else with that environment setting? The log is short enough I can post it here:

Log

2025-10-03T21:52:15.648709Z WARN mm_client_common::conn: skipping TLS verification for private server address
2025-10-03T21:52:16.681766Z INFO winit::platform_impl::platform::x11::window: Guessed window scale factor: 1
2025-10-03T21:52:16.720069Z INFO mm_client::vulkan: selected gpu: "AMD Custom GPU 0932 (RADV VANGOGH)" (0)
2025-10-03T21:52:16.779071Z INFO gilrs_core::platform::platform::gamepad: Gamepad /dev/input/event9 (Microsoft X-Box 360 pad 0) connected.
2025-10-03T21:52:16.779611Z INFO mmclient: launching a new session for for app "steam-austin"
2025-10-03T21:52:19.583285Z INFO mm_client::audio: using audio output device: default
2025-10-03T21:52:19.591282Z INFO gilrs_core::platform::platform::gamepad: Gamepad /dev/input/event9 (Microsoft X-Box 360 pad 0) connected.
2025-10-03T21:52:19.859108Z WARN mm_client::video: unable to determine ffmpeg hw format
2025-10-03T21:52:20.387093Z WARN mm_client::video: unable to determine ffmpeg hw format
2025-10-03T21:53:23.608225Z ERROR mmclient: the requested operation is not supported by Winit

Happy to help if you need anything else! I will probably be offline for the rest of the day, but will find time to help if I can.

(edit: formatting and missed one of my patch lines)

@austinleroy
Copy link
Contributor Author

Oh wait, sorry - I'm apparently bad at rust dependencies. I missed these warnings when building:

warning: patch for cpal uses the features mechanism. default-features and features will not take effect because the patch dependency does not support this mechanism
warning: Patch cpal v0.16.0 (https://github.com/colinmarc/cpal?rev=86aae4edbf0c4600048038d42e8a56edad8b4e9c#86aae4ed) was not used in the crate graph.
Check that the patched package version and available features are compatible
with the dependency requirements. If the patch has a different version from
what is locked in the Cargo.lock file, run cargo update to use the new
version. This may also occur with an optional dependency that is not enabled.

I updated my Cargo.toml and replaced the import for cpal with this:

[dependencies.cpal]
git = "https://github.com/colinmarc/cpal"
rev = "86aae4edbf0c4600048038d42e8a56edad8b4e9c"
features = ["pulseaudio"]

but now I'm getting a version conflict for objc2-encode when trying to build:

error: failed to select a version for objc2-encode.
... required by package objc2 v0.6.1
... which satisfies dependency objc2 = ">=0.6.1, <0.8.0" of package objc2-audio-toolbox v0.3.1
... which satisfies dependency objc2-audio-toolbox = "^0.3.1" of package cpal v0.16.0 (https://github.com/colinmarc/cpal?rev=86aae4edbf0c4600048038d42e8a56edad8b4e9c#86aae4ed)
... which satisfies git dependency cpal of package mm-client v0.7.0 (/home/austin/source/magic-mirror/mm-client)
versions that meet the requirements ^4.1.0 are: 4.1.0
all possible versions conflict with previously selected packages.
previously selected package objc2-encode v4.0.3
... which satisfies dependency objc2-encode = "^4.0.3" (locked to 4.0.3) of package objc2 v0.5.2
... which satisfies dependency objc2 = "^0.5.0" (locked to 0.5.2) of package winit v0.29.15 (https://github.com/rust-windowing/winit?rev=575d978202193abc03c1700f9df9d6e1aa6b03a1#575d9782)
... which satisfies git dependency winit (locked to 0.29.15) of package mm-client v0.7.0 (/home/austin/source/magic-mirror/mm-client)
failed to select a version for objc2-encode which could resolve this conflict

I'm guessing winit might need another patch to be compatible?

@colinmarc
Copy link
Owner

I ran the client with "WAYLAND_DEBUG=1", but it doesn't seem to give any additional output - was I supposed to run something else with that environment setting? The log is short enough I can post it here:

This is connecting via x11, which is surprising. My understanding of the steam deck is that the final compositor is gamescope, which is a wayland compositor? In any case, that might be why cursor locking isn't working.

@colinmarc
Copy link
Owner

I updated winit and friends, and pushed a branch pulseaudio with pulse support. Would you be willing to give that a spin? Thanks!

@austinleroy
Copy link
Contributor Author

I updated winit and friends, and pushed a branch pulseaudio with pulse support. Would you be willing to give that a spin?

I tested it out, and there's some good news and some bad news. The good news is that the audio is no longer popping - it sounds perfectly fine to my ears. The bad news is that the delay got a lot worse... I counted it out to about 15 seconds delay (I'm impressed the audio packet sticks around that long!). I noticed it in my first test, and it seemed so odd that I tried a fresh clean and rebuild to verify, but it was consistent. Again, controls and video were perfectly in sync the whole time.

Out of curiosity, I tested this branch out on my other client (running Arch Linux with sway for the compositor). It also observed the severely delayed audio, although that client works fine with the current main branch. (Full disclosure I did have to add in commit a70b6f9 to the pulseaudio branch run this client).

Also, all of these tests were running steam -gamepadui (I don't have any other apps setup that play audio).

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