Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Distorted audio with moonlight-qt and sdl2-compat on Arch Linux #329

Open
rubin55 opened this issue Feb 8, 2025 · 9 comments
Open

Distorted audio with moonlight-qt and sdl2-compat on Arch Linux #329

rubin55 opened this issue Feb 8, 2025 · 9 comments
Milestone

Comments

@rubin55
Copy link

rubin55 commented Feb 8, 2025

I'm running Arch Linux. I use moonlight-qt to stream my desktop (which runs sunshine) to my laptop (all systems running Arch Linux).

Since the upgrade of sdl3 and introduction of sdl2-compat, I have highly distorted audio. It is specifically not due to network latency, which sounds very different. This sounds like way too loud oversteering or clipping, robotic. It sounds similar to libsdl-org/SDL#12150.

I've made a video to illustrate the issue (zipped, because I can apparently not upload an mp4 directly):
moonlight-qt-sdl2-compat-distorted-audio.zip

@slouken
Copy link
Collaborator

slouken commented Feb 8, 2025

Can you please note the versions of SDL and sdl2-compat you're using?

@slouken slouken transferred this issue from libsdl-org/SDL Feb 8, 2025
@slouken slouken added this to the 2.32.52 milestone Feb 8, 2025
@rubin55
Copy link
Author

rubin55 commented Feb 8, 2025

I'm running Arch Linux with kernel 6.13.1, Gnome on Wayland. Package versions:

  • moonlight-qt 6.1.0-4
  • sdl3 3.2.4-1
  • sdl2-compat 2.30.54-1

@slouken
Copy link
Collaborator

slouken commented Feb 8, 2025

Thanks, we'll take a look!

@cgutman
Copy link
Contributor

cgutman commented Feb 8, 2025

Interesting, I was actually just running this test with the exact same configuration (Arch Linux client too) and audio was okay outputing to an HDMI audio device (monitor).

When you start a stream Moonlight will print some message about the audio configuration which look like:

00:00:12 - SDL Warn (0): Starting audio stream...
00:00:12 - SDL Warn (0): Desired audio buffer: 1440 samples (46080 bytes)
00:00:12 - SDL Warn (0): Obtained audio buffer: 1440 samples (46080 bytes)
00:00:12 - SDL Warn (0): SDL audio driver: pulseaudio
00:00:12 - SDL Warn (0): Audio stream has 8 channels

Can you post those from your test?

@rubin55
Copy link
Author

rubin55 commented Feb 8, 2025

In my case its:

00:00:09 - SDL Warn (0): Starting audio stream...
00:00:09 - SDL Warn (0): Desired audio buffer: 720 samples (5760 bytes)
00:00:09 - SDL Warn (0): Obtained audio buffer: 720 samples (5760 bytes)
00:00:09 - SDL Warn (0): SDL audio driver: pipewire
00:00:09 - SDL Warn (0): Received first video packet after 0 ms
00:00:09 - SDL Warn (0): Audio stream has 2 channels

To be 100% sure it's sdl2-compat related, I downgraded to sdl2 2.30.9-1 and sure enough, audio works normally. When using "regular" sdl2 that log output looks like yours (i.e., pulseaudio instead of pipewire):

00:00:08 - SDL Info (0): Starting audio stream...
00:00:08 - SDL Info (0): Desired audio buffer: 720 samples (5760 bytes)
00:00:08 - SDL Info (0): Obtained audio buffer: 720 samples (5760 bytes)
00:00:08 - SDL Info (0): SDL audio driver: pulseaudio
00:00:08 - SDL Info (0): Audio stream has 2 channels

@rubin55
Copy link
Author

rubin55 commented Feb 8, 2025

Setting the audio driver to pulseaudio gets rid of the distortion when using sdl2-compat:

export SDL_AUDIODRIVER=pulseaudio
moonlight

Note that I also tested downgrade to regular sdl2 and then export SDL_AUDIODRIVER=pipewire to see if the distortion also exists with regular sdl2 combined with pipewire, but it did not (i.e., it worked normally, good sound).

@slouken
Copy link
Collaborator

slouken commented Feb 8, 2025

What happens if you set the environment variable SDL_AUDIO_DEVICE_SAMPLE_FRAMES=720?

@rubin55
Copy link
Author

rubin55 commented Feb 9, 2025

What happens if you set the environment variable SDL_AUDIO_DEVICE_SAMPLE_FRAMES=720?

That works; audiodriver is mentioned as being pipewire in the logs, audio sounds normal!

@slouken
Copy link
Collaborator

slouken commented Feb 10, 2025

@icculus, we should fix whatever bug we have when the SDL2 app sample count doesn't match the actual sample count, but then I think we should have sdl2-compat set SDL_HINT_AUDIO_DEVICE_SAMPLE_FRAMES to the application spec sample count when opening an audio device, so we get as close a match as possible.

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

No branches or pull requests

3 participants