Module: wine Branch: master Commit: 4871cd032f389383798c05178180c0aba8a2c537 URL: https://gitlab.winehq.org/wine/wine/-/commit/4871cd032f389383798c05178180c0a...
Author: Anton Baskanov baskanov@gmail.com Date: Wed Apr 26 11:59:30 2023 +0700
dsound: Preserve freqAccNum value in DSOUND_RecalcFormat().
Resetting it results in position discontinuity. With frequent SetFrequency() calls, this produces audible crackling. The issue affects pedestrian voices in GTA: San Andreas.
---
dlls/dsound/mixer.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/dlls/dsound/mixer.c b/dlls/dsound/mixer.c index dbef1bc40fa..4d0c54735cf 100644 --- a/dlls/dsound/mixer.c +++ b/dlls/dsound/mixer.c @@ -96,6 +96,7 @@ void DSOUND_RecalcFormat(IDirectSoundBufferImpl *dsb) { DWORD ichannels = dsb->pwfx->nChannels; DWORD ochannels = dsb->device->pwfx->nChannels; + LONG64 oldFreqAdjustDen = dsb->freqAdjustDen; WAVEFORMATEXTENSIBLE *pwfxe; BOOL ieee = FALSE;
@@ -130,7 +131,8 @@ void DSOUND_RecalcFormat(IDirectSoundBufferImpl *dsb) /* calculate the 10ms write lead */ dsb->writelead = (dsb->freq / 100) * dsb->pwfx->nBlockAlign;
- dsb->freqAccNum = 0; + if (oldFreqAdjustDen) + dsb->freqAccNum = (dsb->freqAccNum * dsb->freqAdjustDen + oldFreqAdjustDen / 2) / oldFreqAdjustDen;
dsb->get_aux = ieee ? getbpp[4] : getbpp[dsb->pwfx->wBitsPerSample/8 - 1]; dsb->put_aux = putieee32;