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

[Pipewire] Sampling Rate Issues #12269

Open
TatriX opened this issue Feb 11, 2025 · 1 comment
Open

[Pipewire] Sampling Rate Issues #12269

TatriX opened this issue Feb 11, 2025 · 1 comment
Assignees
Milestone

Comments

@TatriX
Copy link

TatriX commented Feb 11, 2025

Hi!

I'm pretty sure my card is 48000Hz by default.
Here's pw-top output (slightly edited by removing unimportant things, like mics):

S   ID  QUANT   RATE    WAIT    BUSY   W/Q   B/Q  ERR FORMAT           NAME
I  167      0      0   0.0us   0.0us  ???   ???     0    F32LE 2 48000 Firefox
R   87    256  48000  99.7us   1.0us  0.02  0.00  885   S32LE 16 48000 alsa_input.usb-BEHRINGER_X-USB_61C77E02-00.pro-input-0
R  113    900  48000  38.7us   7.0us  0.01  0.00    0    F32LE 2 48000  + Firefox
R   89      0      0  43.4us   8.1us  0.01  0.00    0   S32LE 16 48000  + alsa_output.usb-BEHRINGER_X-USB_61C77E02-00.pro-output-0
R  136   1024  44100    ---     ---   ---   ---   662   S16LE 16 44100  + Audio Stream <<<<< SDL3 app

But when I call SDL_GetAudioDeviceFormat on that device I get the following:

Audio Devices (1)
	2. X-USB Pro (id: 19)
		format: S16LE (0x8010); channels: 16; freq: 44100; frames: 1024

and then if I try to actually play audio the app crashes:

Thread 3 "SDLAudioP19" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7ffff5eef6c0 (LWP 1374847)]
0x00007ffff7c22974 in ?? () from /usr/lib/libSDL3.so.0
(gdb) bt
#0  0x00007ffff7c22974 in ?? () from /usr/lib/libSDL3.so.0
#1  0x00007ffff7c2bac1 in ?? () from /usr/lib/libSDL3.so.0
#2  0x00007ffff7c2d052 in ?? () from /usr/lib/libSDL3.so.0
#3  0x00007ffff7c21a26 in ?? () from /usr/lib/libSDL3.so.0
#4  0x00007ffff718ad4d in ?? () from /usr/lib/libpipewire-0.3.so.0
#5  0x00007ffff5f01634 in ?? () from /usr/lib/spa-0.2/audioconvert/libspa-audioconvert.so
#6  0x00007ffff719c599 in ?? () from /usr/lib/libpipewire-0.3.so.0
#7  0x00007ffff716dfb2 in ?? () from /usr/lib/libpipewire-0.3.so.0
#8  0x00007ffff7fa7246 in ?? () from /usr/lib/spa-0.2/support/libspa-support.so
#9  0x00007ffff7191ce7 in ?? () from /usr/lib/libpipewire-0.3.so.0
#10 0x00007ffff76a32ce in ?? () from /usr/lib/libc.so.6
#11 0x00007ffff772829c in ?? () from /usr/lib/libc.so.6

If I specifically request 48000Hz and 2 channels, it doesn't crash, though the audio is distorted, presumably because there's some sort of rate mismatch somewhere.

I request 2 channels, though I still get 16 back not sure if that's expected.
If I then try to create a stream with the spec returned from SDL_GetAudioDeviceFormat, it complains about wrong channels.
So i set channels back to 2, on the spec and now it's fine.

Maybe somewhat related to #12129.

I realize I have a peculiar setup :) So any debugging advice is welcome.
Thanks!

@TatriX
Copy link
Author

TatriX commented Feb 11, 2025

I've just tried SDL_AUDIO_FREQUENCY=48000 hint with SDL_AUDIO_DRIVER=pulseaudio.
That fails to bind a stream with "Invalid audio device instance ID"

Then I tried SDL_AUDIO_DRIVER=alsa and that works perfectly - no distortion or anything.

I think pipewire intercepts alsa calls, so the app doesn't block everything else from accessing the sound card.

@slouken slouken added this to the 3.2.6 milestone Feb 11, 2025
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