-
Notifications
You must be signed in to change notification settings - Fork 132
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 ends up in xrun loop with IPC4 #5284
Comments
One short term workaround is to switch from pipewire to pulseaudio. |
@lvanderree , @carlinigraphy, can you try this (thank for @kv2019i for digging this out!):
This will force PW to add space between the hw and sw pointer. As I have tried to explain, the hw pointer is jumping in case of SOF due to the use of DSP, it is possible that it might jumps over the sw ptr, which is an xrun situation. |
Filed a pipewire issue for this at https://gitlab.freedesktop.org/pipewire/pipewire/-/issues/4489 . It would seem in default settings, Pipewire is trying to restart streaming with a very small amount of data (128 frames when period size is set to 1024), which seems problematic with SOF devices that may transfer multiple milliseconds worth of audio in bursts. Let's keep this ticket open as well until we have confirmed the rootcause. |
@ujfalusi, I've created the config file, and will report back after some testing. |
Oh - that's 2.6ms at 48kHz for xrun restart. DMA could grab 2ms of this to fill the DSP buffer on trigger(start) leaving 32 frames (or 0.6ms) in the driver buffer which may not be expected by pipewire (pipewire may expect 1ms or less to be consumed at restart). |
Hard to say if the config file change above "fixed" things. I've been messing around with BT devices and pulseaudio settings for the last few hours without a crash though. |
@kv2019i, @lgirdwood, I have gathered some numbers without the headroom set to 1024 and it is interesting and might just give some hints. IPC4 The DMA jumps in both cases, but with IPC3 at the first pointer call the hw_ptr is 96 while with IPC4 it moved further to 192. If I apply the headroom change to 1024 then these xruns are not triggered anymore in the first place, so no xrun loop is happening. But this explains why IPC3 appears to work OK and IPC4 ends up in xrun. |
I did some initial tests with this config, after restoring PW |
@kv2019i and indeed, if I set the headroom to 240 (5ms), I don't see xruns with IPC4. |
Update: setting headroom to 1ms (48) also works since it will prevent the initial xrun which would be triggering the flood of xruns. |
It has been reported [1] [2] and confirmed [3] that on MTL+ some application can render audio broken because pipewire ends up in a constant xrun loop.
Pipewire can even think that xrun happens on already running stream which otherwise would not have any problems.
The issue can be reproduced easily by forcing PW to open multiple (all) ALSA PCM devices at once:
Start a web browser and play youtube video or play audio (video is better as it will show the video stuttering)
A) start WebEx standalone application then open the Settings -> Audio
Click on the Test for Ringers and alerts (make sure that All Devices is selected), let it run and then press Stop
The audio (and video) is going stutter
B) start
pavucontrol
if audio remains OK, close it and wait for PW to close the extra PCM device (use [4] for monitoring)
repeat until audio got stuttering
From kernel log it can be seen that when audio got broken all PCMs are rapidly stopped, prepared, started - a standard xrun sequence - but PW will ends up in a loop.
The reason might be that PW is not aware how SOF audio works (which is kind of similar to USB audio): SOF uses the DSP to reduce system power consumption and thus the host side DMA (the hw_ptr) is not running continuously, it is 'jumping' in bursts.
With IPC4 the SOF stack reports the 'delay' that can be used by user space to gain more insights on the progress of the audio.
[1] thesofproject/sof#9695 (comment)
[2] thesofproject/sof#9695 (comment)
[3] thesofproject/sof#9695 (comment)
[4]
watch 'for pcm in /proc/asound/card*/pcm*; do echo ${pcm}; cat ${pcm}/sub0/status; done'
Cc: @lgirdwood, @kv2019i, @ranj063, @bardliao, @lvanderree, @carlinigraphy
The text was updated successfully, but these errors were encountered: