resample: use a float phase in update_rate

My making the phase into a float, the resampler can do finer grained
adjustments, which should improve the stability of adaptive
resampling
This commit is contained in:
Dimitrios Katsaros 2024-02-16 13:42:31 +01:00 committed by Wim Taymans
parent 764ae650e2
commit 77f6c009c1
2 changed files with 7 additions and 5 deletions

View file

@ -134,7 +134,8 @@ static inline uint32_t calc_gcd(uint32_t a, uint32_t b)
static void impl_native_update_rate(struct resample *r, double rate)
{
struct native_data *data = r->data;
uint32_t in_rate, out_rate, phase, gcd, old_out_rate;
uint32_t in_rate, out_rate, gcd, old_out_rate;
float phase;
if (SPA_LIKELY(data->rate == rate))
return;
@ -149,7 +150,7 @@ static void impl_native_update_rate(struct resample *r, double rate)
out_rate /= gcd;
data->rate = rate;
data->phase = phase * out_rate / old_out_rate;
data->phase = phase * out_rate / (float)old_out_rate;
data->in_rate = in_rate;
data->out_rate = out_rate;