Adds a simple throttling mechanism to prevent pointer overlaps when winepulse is faster than the audio server. Winepulse uses a fake clock to advance the pointers: ```c /* regardless of what PA does, advance one period */ adv_bytes = min(stream->period_bytes, stream->held_bytes); stream->lcl_offs_bytes += adv_bytes; stream->lcl_offs_bytes %= stream->real_bufsize_bytes; stream->held_bytes -= adv_bytes; ``` And if winepulse is just a little bit faster than the audio server (does not matter PW or PA), it inevitably leads to pointer overlaps and therefore crackling. This patch proposes a throttling mechanism that is somewhat similar to winealsa - don't ever tell the application we have more space than we actually do. The problem could probably be resolved by making the fake clock perfectly mimic the audio server, but this is orders of magnitude more difficult. Winealsa achieves similar idea this way: `data_frames_played = min(stream->data_in_alsa_frames, avail); stream->held_frames -= data_frames_played;` The issue I am trying to fix is very real - it can cause crackling in any game you try. You don't have to hear the crackling to see that it's mathematically inevitable by logging the difference between held_bytes and pa_held_bytes. If it becomes smaller and goes negative - crackling is inevitable, because pointers will overlap. The issue is not tied to PW or PA specifically, I observed the behavior with both. In regards to how it interacts with MR https://gitlab.winehq.org/wine/wine/-/merge_requests/8628 - no issues in GoWR in my testing, unless you try enabling PROTON_LOG for pulse (which is very spammy in this game), and spam yes on all threads - which would also cause stream resets with unchanged winepulse, just later. Additionally, this patch has already been implemented in Proton GE and Proton CachyOS for about two months now - no issues and it has helped some people. There are not a lot of open issues regarding audio because unfortunately crackling is very underreported - you can look at GoWR protondb page before the 8628 MR - it definitely crackled, but many reports were not stating so. There are a lot of reports of crackling on virtually any game on protondb. You can also see people solve crackling issues for Arc Raiders (which I personally had myself before patching winepulse) by using winealsa: https://github.com/ValveSoftware/Proton/issues/9164#issuecomment-3529760335. One thing to look out for though - in CI spatialaudio tests will fail, but they fail literally the same way they do with winealsa - this is because there is nowhere for audio to go in a virtual environment, pa_held_bytes balloons while held_bytes drops, they overlap and held_bytes stops moving, and the tests start failing. No issues locally. I have previously tried tackling crackling in this pr: https://gitlab.winehq.org/wine/wine/-/merge_requests/9840 (although it was for underflows instead). My approach was admittedly incorrect, however it did help me discover this issue. Good audio is fundamental in my opinion, I would really love to see crackling-free audio for everyone regardless of proton version. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10792