Matteo Bruni (@Mystral) commented about dlls/dsound/mixer.c:
* Note that this function will overwrite up to fir_width - 1 frames before and * after output[]. */ -static void downsample(LONG64 freq_adjust_num, LONG64 freq_adjust_den, LONG64 freq_acc_start, - float firgain, UINT required_input, float *input, float *output) +static void downsample(DWORD freq_adjust_den, DWORD freq_acc_start, float firgain, + UINT required_input, float *input, float *output) { int j;
for (j = 0; j < required_input; ++j) { - LONG64 opos_num = freq_adjust_den - freq_acc_start + j * freq_adjust_den + freq_adjust_num - 1; + LONG64 opos_num = freq_adjust_den - freq_acc_start + j * (LONG64)freq_adjust_den + ~0u; /* opos is in the range [-(fir_width - 1), count) */ - int opos = opos_num / freq_adjust_num - fir_width; + int opos = (int)(opos_num >> 32) - fir_width; It might be nice to introduce a couple of `#define`s, like:
#define POS_FRAC_SHIFT 32
#define POS_FRAC_MASK ((1ull << POS_FRAC_SHIFT) - 1)
I'm not attached to the specific naming. The choice here comes from the idea of eventually ending up with something like https://gitlab.winehq.org/Mystral/wine/-/commit/aca8b39927dd75268cb18fe19307..., which still seems like a good improvement to have :slight_smile: -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10423#note_134503