Matteo Bruni (@Mystral) commented about dlls/dsound/mixer.c:
}
for(i = 0; i < count; ++i) { - LONG64 fir_steps_num = (freqAcc_start + i * dsb->freqAdjustNum) * dsbfirstep; - UINT int_fir_steps = fir_steps_num / dsb->freqAdjustDen; - UINT ipos = int_fir_steps / dsbfirstep; + LONG64 ipos_num = freqAcc_start + i * dsb->freqAdjustNum; + UINT ipos = ipos_num / dsb->freqAdjustDen;
- UINT idx = dsbfirstep - 1 - int_fir_steps % dsbfirstep; - float rem = 1.0f - fir_steps_num % dsb->freqAdjustDen / (float)dsb->freqAdjustDen; + UINT idx_num = ipos_num % dsb->freqAdjustDen * dsbfirstep;
I had a hard time decoding the modulo here and I kept thinking that sometimes it might not give an exact result. For the former, after the modulo we have a number in the range `[0,freqAdjustDen)` representing the position within the specific input sample. Multiplying it by `dsbfirstep / freqAdjustDen` we compute `idx` in the expected `dsbfirstep` units. For the latter, I guess this works out fine in practice, with `freqAdjustDen` >> `dsbfirstep`. I don't know that there is anything to change here. I guess some kind of comment might be nice, although I'm hard pressed with coming up with a good comment myself. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10146#note_130090