Fix compilation with -Werror=float-conversion

Better make the conversions explicit so that we don't get any surprises.

Fixes #4065
This commit is contained in:
Wim Taymans 2024-06-18 12:17:56 +02:00
parent 50870aac57
commit 1ae4374ccf
71 changed files with 286 additions and 284 deletions

View file

@ -4,7 +4,7 @@
#include <math.h>
#define M_PI_M2 ( M_PI + M_PI )
#define M_PI_M2f ( M_PIf + M_PIf )
#define DEFINE_SINE(type,scale) \
static void \
@ -17,24 +17,24 @@ audio_test_src_create_sine_##type (struct impl *this, type *samples, size_t n_sa
float volume = this->props.volume; \
\
channels = this->port.current_format.info.raw.channels; \
step = M_PI_M2 * freq / this->port.current_format.info.raw.rate; \
step = M_PI_M2f * freq / this->port.current_format.info.raw.rate; \
amp = volume * scale; \
\
for (i = 0; i < n_samples; i++) { \
type val; \
this->port.accumulator += step; \
if (this->port.accumulator >= M_PI_M2) \
this->port.accumulator -= M_PI_M2; \
if (this->port.accumulator >= M_PI_M2f) \
this->port.accumulator -= M_PI_M2f; \
val = (type) (sin (this->port.accumulator) * amp); \
for (c = 0; c < channels; ++c) \
*samples++ = val; \
} \
}
DEFINE_SINE(int16_t, 32767.0);
DEFINE_SINE(int32_t, 2147483647.0);
DEFINE_SINE(float, 1.0);
DEFINE_SINE(double, 1.0);
DEFINE_SINE(int16_t, 32767.0f);
DEFINE_SINE(int32_t, 2147483647.0f);
DEFINE_SINE(float, 1.0f);
DEFINE_SINE(double, 1.0f);
static const render_func_t sine_funcs[] = {
(render_func_t) audio_test_src_create_sine_int16_t,