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

@ -63,7 +63,7 @@ static void on_process(void *userdata)
for (n = c; n < n_samples; n += n_channels)
max = fmaxf(max, fabsf(samples[n]));
peak = SPA_CLAMP(max * 30, 0, 39);
peak = (uint32_t)SPA_CLAMPF(max * 30, 0.f, 39.f);
fprintf(stdout, "channel %d: |%*s%*s| peak:%f\n",
c, peak+1, "*", 40 - peak, "", max);

View file

@ -16,17 +16,17 @@
#include <pipewire/pipewire.h>
#include <pipewire/filter.h>
#define M_PI_M2 ( M_PI + M_PI )
#define M_PI_M2f ( M_PIf + M_PIf )
#define DEFAULT_RATE 44100
#define DEFAULT_FREQ 440
#define DEFAULT_VOLUME 0.7
#define DEFAULT_VOLUME 0.7f
struct data;
struct port {
struct data *data;
double accumulator;
float accumulator;
};
struct data {
@ -61,11 +61,11 @@ static void on_process(void *userdata, struct spa_io_position *position)
return;
for (i = 0; i < n_samples; i++) {
out_port->accumulator += M_PI_M2 * DEFAULT_FREQ / DEFAULT_RATE;
if (out_port->accumulator >= M_PI_M2)
out_port->accumulator -= M_PI_M2;
out_port->accumulator += M_PI_M2f * DEFAULT_FREQ / DEFAULT_RATE;
if (out_port->accumulator >= M_PI_M2f)
out_port->accumulator -= M_PI_M2f;
*out++ = sin(out_port->accumulator) * DEFAULT_VOLUME;
*out++ = sinf(out_port->accumulator) * DEFAULT_VOLUME;
}
}

View file

@ -17,17 +17,17 @@
#include <pipewire/pipewire.h>
#define M_PI_M2 ( M_PI + M_PI )
#define M_PI_M2f ( M_PIf + M_PIf )
#define DEFAULT_RATE 44100
#define DEFAULT_CHANNELS 2
#define DEFAULT_VOLUME 0.7
#define DEFAULT_VOLUME 0.7f
struct data {
struct pw_main_loop *loop;
struct pw_stream *stream;
double accumulator;
float accumulator;
};
static void fill_f32(struct data *d, void *dest, int n_frames)
@ -36,11 +36,11 @@ static void fill_f32(struct data *d, void *dest, int n_frames)
int i, c;
for (i = 0; i < n_frames; i++) {
d->accumulator += M_PI_M2 * 440 / DEFAULT_RATE;
if (d->accumulator >= M_PI_M2)
d->accumulator -= M_PI_M2;
d->accumulator += M_PI_M2f * 440 / DEFAULT_RATE;
if (d->accumulator >= M_PI_M2f)
d->accumulator -= M_PI_M2f;
val = sin(d->accumulator) * DEFAULT_VOLUME;
val = sinf(d->accumulator) * DEFAULT_VOLUME;
for (c = 0; c < DEFAULT_CHANNELS; c++)
*dst++ = val;
}

View file

@ -29,7 +29,7 @@
#include "sdl.h"
#define M_PI_M2 ( M_PI + M_PI )
#define M_PI_M2f ( M_PIf + M_PIf )
#define MAX_BUFFERS 64
@ -65,7 +65,7 @@ struct data {
struct spa_io_buffers *io;
struct spa_io_sequence *io_notify;
uint32_t io_notify_size;
double param_accum;
float param_accum;
uint8_t buffer[1024];
@ -106,13 +106,13 @@ static void update_param(struct data *data)
spa_pod_builder_control(&b, 0, SPA_CONTROL_Properties);
spa_pod_builder_push_object(&b, &f[1], SPA_TYPE_OBJECT_Props, 0);
spa_pod_builder_prop(&b, SPA_PROP_contrast, 0);
spa_pod_builder_float(&b, (sin(data->param_accum) * 127.0) + 127.0);
spa_pod_builder_float(&b, (sinf(data->param_accum) * 127.0f) + 127.0f);
spa_pod_builder_pop(&b, &f[1]);
spa_pod_builder_pop(&b, &f[0]);
data->param_accum += M_PI_M2 / 30.0;
if (data->param_accum >= M_PI_M2)
data->param_accum -= M_PI_M2;
data->param_accum += M_PI_M2f / 30.0f;
if (data->param_accum >= M_PI_M2f)
data->param_accum -= M_PI_M2f;
}
static int impl_send_command(void *object, const struct spa_command *command)

View file

@ -23,7 +23,7 @@
#include <pipewire/pipewire.h>
#define M_PI_M2 ( M_PI + M_PI )
#define M_PI_M2f ( M_PIf + M_PIf )
#define BUFFER_SAMPLES 128
#define MAX_BUFFERS 32
@ -64,8 +64,8 @@ struct data {
uint32_t n_buffers;
struct spa_list empty;
double accumulator;
double volume_accum;
float accumulator;
float volume_accum;
};
static void update_volume(struct data *data)
@ -81,13 +81,13 @@ static void update_volume(struct data *data)
spa_pod_builder_control(&b, 0, SPA_CONTROL_Properties);
spa_pod_builder_push_object(&b, &f[1], SPA_TYPE_OBJECT_Props, 0);
spa_pod_builder_prop(&b, SPA_PROP_volume, 0);
spa_pod_builder_float(&b, (sin(data->volume_accum) / 2.0) + 0.5);
spa_pod_builder_float(&b, (sinf(data->volume_accum) / 2.0f) + 0.5f);
spa_pod_builder_pop(&b, &f[1]);
spa_pod_builder_pop(&b, &f[0]);
data->volume_accum += M_PI_M2 / 1000.0;
if (data->volume_accum >= M_PI_M2)
data->volume_accum -= M_PI_M2;
data->volume_accum += M_PI_M2f / 1000.0f;
if (data->volume_accum >= M_PI_M2f)
data->volume_accum -= M_PI_M2f;
}
static int impl_send_command(void *object, const struct spa_command *command)
@ -364,11 +364,11 @@ static void fill_f32(struct data *d, void *dest, int avail)
for (i = 0; i < n_samples; i++) {
float val;
d->accumulator += M_PI_M2 * 440 / d->format.rate;
if (d->accumulator >= M_PI_M2)
d->accumulator -= M_PI_M2;
d->accumulator += M_PI_M2f * 440 / d->format.rate;
if (d->accumulator >= M_PI_M2f)
d->accumulator -= M_PI_M2f;
val = sin(d->accumulator);
val = sinf(d->accumulator);
for (c = 0; c < d->format.channels; c++)
*dst++ = val;
@ -385,11 +385,11 @@ static void fill_s16(struct data *d, void *dest, int avail)
for (i = 0; i < n_samples; i++) {
int16_t val;
d->accumulator += M_PI_M2 * 440 / d->format.rate;
if (d->accumulator >= M_PI_M2)
d->accumulator -= M_PI_M2;
d->accumulator += M_PI_M2f * 440 / d->format.rate;
if (d->accumulator >= M_PI_M2f)
d->accumulator -= M_PI_M2f;
val = (int16_t) (sin(d->accumulator) * 32767.0);
val = (int16_t) (sinf(d->accumulator) * 32767.0f);
for (c = 0; c < d->format.channels; c++)
*dst++ = val;

View file

@ -128,10 +128,10 @@ on_process(void *_data, struct spa_io_position *position)
for (i = 0; i < data->position->video.size.height; i++) {
struct pixel *p = (struct pixel *) src;
for (j = 0; j < data->position->video.size.width; j++) {
dst[j * 4 + 0] = SPA_CLAMP(p[j].r * 255.0f, 0, 255);
dst[j * 4 + 1] = SPA_CLAMP(p[j].g * 255.0f, 0, 255);
dst[j * 4 + 2] = SPA_CLAMP(p[j].b * 255.0f, 0, 255);
dst[j * 4 + 3] = SPA_CLAMP(p[j].a * 255.0f, 0, 255);
dst[j * 4 + 0] = SPA_CLAMP((uint8_t)(p[j].r * 255.0f), 0, 255);
dst[j * 4 + 1] = SPA_CLAMP((uint8_t)(p[j].g * 255.0f), 0, 255);
dst[j * 4 + 2] = SPA_CLAMP((uint8_t)(p[j].b * 255.0f), 0, 255);
dst[j * 4 + 3] = SPA_CLAMP((uint8_t)(p[j].a * 255.0f), 0, 255);
}
src += sstride;
dst += dstride;

View file

@ -123,18 +123,18 @@ static void on_process(void *userdata)
}
if ((mc = spa_buffer_find_meta_data(buf, SPA_META_VideoCrop, sizeof(*mc)))) {
data->crop = (sin(data->accumulator) + 1.0) * 32.0;
mc->region.position.x = data->crop;
mc->region.position.y = data->crop;
mc->region.size.width = data->position->video.size.width - data->crop*2;
mc->region.size.height = data->position->video.size.height - data->crop*2;
mc->region.position.x = (int32_t)data->crop;
mc->region.position.y = (int32_t)data->crop;
mc->region.size.width = data->position->video.size.width - (int32_t)(data->crop*2);
mc->region.size.height = data->position->video.size.height - (int32_t)(data->crop*2);
}
if ((mcs = spa_buffer_find_meta_data(buf, SPA_META_Cursor, sizeof(*mcs)))) {
struct spa_meta_bitmap *mb;
uint32_t *bitmap, color;
mcs->id = 1;
mcs->position.x = (sin(data->accumulator) + 1.0) * 160.0 + 80;
mcs->position.y = (cos(data->accumulator) + 1.0) * 100.0 + 50;
mcs->position.x = (int32_t)((sin(data->accumulator) + 1.0) * 160.0 + 80);
mcs->position.y = (int32_t)((cos(data->accumulator) + 1.0) * 100.0 + 50);
mcs->hotspot.x = 0;
mcs->hotspot.y = 0;
mcs->bitmap_offset = sizeof(struct spa_meta_cursor);
@ -147,7 +147,7 @@ static void on_process(void *userdata)
mb->offset = sizeof(struct spa_meta_bitmap);
bitmap = SPA_PTROFF(mb, mb->offset, uint32_t);
color = (cos(data->accumulator) + 1.0) * (1 << 23);
color = (uint32_t)((cos(data->accumulator) + 1.0) * (1 << 23));
color |= 0xff000000;
draw_elipse(bitmap, mb->size.width, mb->size.height, color);

View file

@ -197,10 +197,10 @@ on_process(void *_data)
for (i = 0; i < data->size.height; i++) {
struct pixel *p = (struct pixel *) src;
for (j = 0; j < data->size.width; j++) {
dst[j * 4 + 0] = SPA_CLAMP(p[j].r * 255.0f, 0, 255);
dst[j * 4 + 1] = SPA_CLAMP(p[j].g * 255.0f, 0, 255);
dst[j * 4 + 2] = SPA_CLAMP(p[j].b * 255.0f, 0, 255);
dst[j * 4 + 3] = SPA_CLAMP(p[j].a * 255.0f, 0, 255);
dst[j * 4 + 0] = SPA_CLAMP((uint8_t)(p[j].r * 255.0f), 0u, 255u);
dst[j * 4 + 1] = SPA_CLAMP((uint8_t)(p[j].g * 255.0f), 0u, 255u);
dst[j * 4 + 2] = SPA_CLAMP((uint8_t)(p[j].b * 255.0f), 0u, 255u);
dst[j * 4 + 3] = SPA_CLAMP((uint8_t)(p[j].a * 255.0f), 0u, 255u);
}
src += sstride;
dst += dstride;

View file

@ -205,10 +205,10 @@ on_process(void *_data)
for (i = 0; i < data->size.height; i++) {
struct pixel *p = (struct pixel *) src;
for (j = 0; j < data->size.width; j++) {
dst[j * 4 + 0] = SPA_CLAMP(p[j].r * 255.0f, 0, 255);
dst[j * 4 + 1] = SPA_CLAMP(p[j].g * 255.0f, 0, 255);
dst[j * 4 + 2] = SPA_CLAMP(p[j].b * 255.0f, 0, 255);
dst[j * 4 + 3] = SPA_CLAMP(p[j].a * 255.0f, 0, 255);
dst[j * 4 + 0] = SPA_CLAMP((uint8_t)(p[j].r * 255.0f), 0u, 255u);
dst[j * 4 + 1] = SPA_CLAMP((uint8_t)(p[j].g * 255.0f), 0u, 255u);
dst[j * 4 + 2] = SPA_CLAMP((uint8_t)(p[j].b * 255.0f), 0u, 255u);
dst[j * 4 + 3] = SPA_CLAMP((uint8_t)(p[j].a * 255.0f), 0u, 255u);
}
src += sstride;
dst += dstride;

View file

@ -111,18 +111,18 @@ static void on_process(void *userdata)
}
if ((mc = spa_buffer_find_meta_data(buf, SPA_META_VideoCrop, sizeof(*mc)))) {
data->crop = (sin(data->accumulator) + 1.0) * 32.0;
mc->region.position.x = data->crop;
mc->region.position.y = data->crop;
mc->region.size.width = data->format.size.width - data->crop*2;
mc->region.size.height = data->format.size.height - data->crop*2;
mc->region.position.x = (int32_t)data->crop;
mc->region.position.y = (int32_t)data->crop;
mc->region.size.width = data->format.size.width - (int32_t)(data->crop*2);
mc->region.size.height = data->format.size.height - (int32_t)(data->crop*2);
}
if ((mcs = spa_buffer_find_meta_data(buf, SPA_META_Cursor, sizeof(*mcs)))) {
struct spa_meta_bitmap *mb;
uint32_t *bitmap, color;
mcs->id = 1;
mcs->position.x = (sin(data->accumulator) + 1.0) * 160.0 + 80;
mcs->position.y = (cos(data->accumulator) + 1.0) * 100.0 + 50;
mcs->position.x = (int32_t)((sin(data->accumulator) + 1.0) * 160.0 + 80);
mcs->position.y = (int32_t)((cos(data->accumulator) + 1.0) * 100.0 + 50);
mcs->hotspot.x = 0;
mcs->hotspot.y = 0;
mcs->bitmap_offset = sizeof(struct spa_meta_cursor);
@ -135,7 +135,7 @@ static void on_process(void *userdata)
mb->offset = sizeof(struct spa_meta_bitmap);
bitmap = SPA_PTROFF(mb, mb->offset, uint32_t);
color = (cos(data->accumulator) + 1.0) * (1 << 23);
color = (uint32_t)((cos(data->accumulator) + 1.0) * (1 << 23));
color |= 0xff000000;
draw_elipse(bitmap, mb->size.width, mb->size.height, color);

View file

@ -185,18 +185,18 @@ static void on_process(void *userdata)
}
if ((mc = spa_buffer_find_meta_data(buf, SPA_META_VideoCrop, sizeof(*mc)))) {
data->crop = (sin(data->accumulator) + 1.0) * 32.0;
mc->region.position.x = data->crop;
mc->region.position.y = data->crop;
mc->region.size.width = data->format.size.width - data->crop*2;
mc->region.size.height = data->format.size.height - data->crop*2;
mc->region.position.x = (int32_t)data->crop;
mc->region.position.y = (int32_t)data->crop;
mc->region.size.width = data->format.size.width - (int32_t)(data->crop*2);
mc->region.size.height = data->format.size.height - (int32_t)(data->crop*2);
}
if ((mcs = spa_buffer_find_meta_data(buf, SPA_META_Cursor, sizeof(*mcs)))) {
struct spa_meta_bitmap *mb;
uint32_t *bitmap, color;
mcs->id = 1;
mcs->position.x = (sin(data->accumulator) + 1.0) * 160.0 + 80;
mcs->position.y = (cos(data->accumulator) + 1.0) * 100.0 + 50;
mcs->position.x = (int32_t)((sin(data->accumulator) + 1.0) * 160.0 + 80);
mcs->position.y = (int32_t)((cos(data->accumulator) + 1.0) * 100.0 + 50);
mcs->hotspot.x = 0;
mcs->hotspot.y = 0;
mcs->bitmap_offset = sizeof(struct spa_meta_cursor);
@ -209,7 +209,7 @@ static void on_process(void *userdata)
mb->offset = sizeof(struct spa_meta_bitmap);
bitmap = SPA_PTROFF(mb, mb->offset, uint32_t);
color = (cos(data->accumulator) + 1.0) * (1 << 23);
color = (uint32_t)((cos(data->accumulator) + 1.0) * (1 << 23));
color |= 0xff000000;
draw_elipse(bitmap, mb->size.width, mb->size.height, color);

View file

@ -115,18 +115,18 @@ static void on_process(void *userdata)
}
if ((mc = spa_buffer_find_meta_data(buf, SPA_META_VideoCrop, sizeof(*mc)))) {
data->crop = (sin(data->accumulator) + 1.0) * 32.0;
mc->region.position.x = data->crop;
mc->region.position.y = data->crop;
mc->region.size.width = data->format.size.width - data->crop*2;
mc->region.size.height = data->format.size.height - data->crop*2;
mc->region.position.x = (int32_t)data->crop;
mc->region.position.y = (int32_t)data->crop;
mc->region.size.width = data->format.size.width - (int32_t)(data->crop*2);
mc->region.size.height = data->format.size.height - (int32_t)(data->crop*2);
}
if ((mcs = spa_buffer_find_meta_data(buf, SPA_META_Cursor, sizeof(*mcs)))) {
struct spa_meta_bitmap *mb;
uint32_t *bitmap, color;
mcs->id = 1;
mcs->position.x = (sin(data->accumulator) + 1.0) * 160.0 + 80;
mcs->position.y = (cos(data->accumulator) + 1.0) * 100.0 + 50;
mcs->position.x = (int32_t)((sin(data->accumulator) + 1.0) * 160.0 + 80);
mcs->position.y = (int32_t)((cos(data->accumulator) + 1.0) * 100.0 + 50);
mcs->hotspot.x = 0;
mcs->hotspot.y = 0;
mcs->bitmap_offset = sizeof(struct spa_meta_cursor);
@ -139,7 +139,7 @@ static void on_process(void *userdata)
mb->offset = sizeof(struct spa_meta_bitmap);
bitmap = SPA_PTROFF(mb, mb->offset, uint32_t);
color = (cos(data->accumulator) + 1.0) * (1 << 23);
color = (uint32_t)((cos(data->accumulator) + 1.0) * (1 << 23));
color |= 0xff000000;
draw_elipse(bitmap, mb->size.width, mb->size.height, color);

View file

@ -111,18 +111,18 @@ static void on_process(void *userdata)
}
if ((mc = spa_buffer_find_meta_data(buf, SPA_META_VideoCrop, sizeof(*mc)))) {
data->crop = (sin(data->accumulator) + 1.0) * 32.0;
mc->region.position.x = data->crop;
mc->region.position.y = data->crop;
mc->region.size.width = data->format.size.width - data->crop*2;
mc->region.size.height = data->format.size.height - data->crop*2;
mc->region.position.x = (int32_t)data->crop;
mc->region.position.y = (int32_t)data->crop;
mc->region.size.width = data->format.size.width - (int32_t)(data->crop*2);
mc->region.size.height = data->format.size.height - (int32_t)(data->crop*2);
}
if ((mcs = spa_buffer_find_meta_data(buf, SPA_META_Cursor, sizeof(*mcs)))) {
struct spa_meta_bitmap *mb;
uint32_t *bitmap, color;
mcs->id = 1;
mcs->position.x = (sin(data->accumulator) + 1.0) * 160.0 + 80;
mcs->position.y = (cos(data->accumulator) + 1.0) * 100.0 + 50;
mcs->position.x = (int32_t)((sin(data->accumulator) + 1.0) * 160.0 + 80);
mcs->position.y = (int32_t)((cos(data->accumulator) + 1.0) * 100.0 + 50);
mcs->hotspot.x = 0;
mcs->hotspot.y = 0;
mcs->bitmap_offset = sizeof(struct spa_meta_cursor);
@ -135,7 +135,7 @@ static void on_process(void *userdata)
mb->offset = sizeof(struct spa_meta_bitmap);
bitmap = SPA_PTROFF(mb, mb->offset, uint32_t);
color = (cos(data->accumulator) + 1.0) * (1 << 23);
color = (uint32_t)((cos(data->accumulator) + 1.0) * (1 << 23));
color |= 0xff000000;
draw_elipse(bitmap, mb->size.width, mb->size.height, color);

View file

@ -78,10 +78,10 @@ static void maap_message_debug(struct maap *maap, const struct avb_packet_maap *
pw_log_info(" conflict-count: %d", AVB_PACKET_MAAP_GET_CONFLICT_COUNT(p));
}
#define PROBE_TIMEOUT(n) ((n) + (MAAP_PROBE_INTERVAL_MS + \
drand48() * MAAP_PROBE_INTERVAL_VAR_MS) * SPA_NSEC_PER_MSEC)
#define ANNOUNCE_TIMEOUT(n) ((n) + (MAAP_ANNOUNCE_INTERVAL_MS + \
drand48() * MAAP_ANNOUNCE_INTERVAL_VAR_MS) * SPA_NSEC_PER_MSEC)
#define PROBE_TIMEOUT(n) (uint64_t)(((n) + (MAAP_PROBE_INTERVAL_MS + \
drand48() * MAAP_PROBE_INTERVAL_VAR_MS) * SPA_NSEC_PER_MSEC))
#define ANNOUNCE_TIMEOUT(n) (uint64_t)(((n) + (MAAP_ANNOUNCE_INTERVAL_MS + \
drand48() * MAAP_ANNOUNCE_INTERVAL_VAR_MS) * SPA_NSEC_PER_MSEC))
static int make_new_address(struct maap *maap, uint64_t now, int range)
{

View file

@ -1022,12 +1022,12 @@ static struct spa_pod *get_prop_info(struct graph *graph, struct spa_pod_builder
}
} else if (p->hint & FC_HINT_INTEGER) {
if (min == max) {
spa_pod_builder_int(b, def);
spa_pod_builder_int(b, (int32_t)def);
} else {
spa_pod_builder_push_choice(b, &f[1], SPA_CHOICE_Range, 0);
spa_pod_builder_int(b, def);
spa_pod_builder_int(b, min);
spa_pod_builder_int(b, max);
spa_pod_builder_int(b, (int32_t)def);
spa_pod_builder_int(b, (int32_t)min);
spa_pod_builder_int(b, (int32_t)max);
spa_pod_builder_pop(b, &f[1]);
}
} else {
@ -1073,7 +1073,7 @@ static struct spa_pod *get_props_param(struct graph *graph, struct spa_pod_build
if (p->hint & FC_HINT_BOOLEAN) {
spa_pod_builder_bool(b, port->control_data[0] <= 0.0f ? false : true);
} else if (p->hint & FC_HINT_INTEGER) {
spa_pod_builder_int(b, port->control_data[0]);
spa_pod_builder_int(b, (int32_t)port->control_data[0]);
} else {
spa_pod_builder_float(b, port->control_data[0]);
}
@ -1140,7 +1140,7 @@ static int parse_params(struct graph *graph, const struct spa_pod *pod)
if (spa_pod_parser_get_float(&prs, &value) >= 0) {
val = &value;
} else if (spa_pod_parser_get_double(&prs, &dbl_val) >= 0) {
value = dbl_val;
value = (float)dbl_val;
val = &value;
} else if (spa_pod_parser_get_int(&prs, &int_val) >= 0) {
value = int_val;
@ -1217,7 +1217,7 @@ static int sync_volume(struct graph *graph, struct volume *vol)
float v = vol->mute ? 0.0f : vol->volumes[i];
switch (vol->scale[n_port]) {
case SCALE_CUBIC:
v = cbrt(v);
v = cbrtf(v);
break;
}
v = v * (vol->max[n_port] - vol->min[n_port]) + vol->min[n_port];

View file

@ -19,11 +19,11 @@ static void set_coefficient(struct biquad *bq, double b0, double b1, double b2,
double a0, double a1, double a2)
{
double a0_inv = 1 / a0;
bq->b0 = b0 * a0_inv;
bq->b1 = b1 * a0_inv;
bq->b2 = b2 * a0_inv;
bq->a1 = a1 * a0_inv;
bq->a2 = a2 * a0_inv;
bq->b0 = (float)(b0 * a0_inv);
bq->b1 = (float)(b1 * a0_inv);
bq->b2 = (float)(b2 * a0_inv);
bq->a1 = (float)(a1 * a0_inv);
bq->a2 = (float)(a2 * a0_inv);
}
static void biquad_lowpass(struct biquad *bq, double cutoff, double resonance)

View file

@ -752,10 +752,10 @@ static float *create_hilbert(const char *filename, float gain, int delay, int of
if (samples == NULL)
return NULL;
gain *= 2 / M_PI;
gain *= 2 / M_PIf;
h = length / 2;
for (i = 1; i < h; i += 2) {
v = (gain / i) * (0.43f + 0.57f * cosf(i * M_PI / h));
v = (gain / i) * (0.43f + 0.57f * cosf(i * M_PIf / h));
samples[delay + h + i] = -v;
samples[delay + h - i] = v;
}
@ -1134,7 +1134,7 @@ static void *delay_instantiate(const struct fc_descriptor * Descriptor,
return NULL;
impl->rate = SampleRate;
impl->buffer_samples = max_delay * impl->rate;
impl->buffer_samples = (uint32_t)(max_delay * impl->rate);
pw_log_info("max-delay:%f seconds rate:%lu samples:%d", max_delay, impl->rate, impl->buffer_samples);
impl->buffer = calloc(impl->buffer_samples, sizeof(float));
@ -1163,7 +1163,7 @@ static void delay_run(void * Instance, unsigned long SampleCount)
uint32_t r, w;
if (delay != impl->delay) {
impl->delay_samples = SPA_CLAMP(delay * impl->rate, 0, impl->buffer_samples-1);
impl->delay_samples = SPA_CLAMP((uint32_t)(delay * impl->rate), 0u, impl->buffer_samples-1);
impl->delay = delay;
}
r = impl->ptr;
@ -1453,7 +1453,7 @@ static struct fc_port exp_ports[] = {
{ .index = 4,
.name = "Base",
.flags = FC_PORT_INPUT | FC_PORT_CONTROL,
.def = M_E, .min = -10.0f, .max = 10.0f
.def = M_Ef, .min = -10.0f, .max = 10.0f
},
};
@ -1510,7 +1510,7 @@ static struct fc_port log_ports[] = {
{ .index = 4,
.name = "Base",
.flags = FC_PORT_INPUT | FC_PORT_CONTROL,
.def = M_E, .min = 2.0f, .max = 100.0f
.def = M_Ef, .min = 2.0f, .max = 100.0f
},
{ .index = 5,
.name = "M1",
@ -1611,7 +1611,7 @@ static const struct fc_descriptor mult_desc = {
.cleanup = builtin_cleanup,
};
#define M_PI_M2 ( M_PI + M_PI )
#define M_PI_M2f ( M_PIf + M_PIf )
/* sine */
static void sine_run(void * Instance, unsigned long SampleCount)
@ -1626,13 +1626,13 @@ static void sine_run(void * Instance, unsigned long SampleCount)
for (n = 0; n < SampleCount; n++) {
if (out != NULL)
out[n] = sin(impl->accum) * ampl + offs;
out[n] = sinf(impl->accum) * ampl + offs;
if (notify != NULL && n == 0)
notify[0] = sin(impl->accum) * ampl + offs;
notify[0] = sinf(impl->accum) * ampl + offs;
impl->accum += M_PI_M2 * freq / impl->rate;
if (impl->accum >= M_PI_M2)
impl->accum -= M_PI_M2;
impl->accum += M_PI_M2f * freq / impl->rate;
if (impl->accum >= M_PI_M2f)
impl->accum -= M_PI_M2f;
}
}
@ -1658,7 +1658,7 @@ static struct fc_port sine_ports[] = {
{ .index = 4,
.name = "Phase",
.flags = FC_PORT_INPUT | FC_PORT_CONTROL,
.def = 0.0f, .min = -M_PI, .max = M_PI
.def = 0.0f, .min = -M_PIf, .max = M_PIf
},
{ .index = 5,
.name = "Offset",

View file

@ -1273,7 +1273,7 @@ static void rffti1_ps(int n, float *wa, int *ifac)
int k1, j, ii;
int nf = decompose(n, ifac, ntryh);
float argh = (2 * M_PI) / n;
float argh = (2 * M_PIf) / n;
int is = 0;
int nfm1 = nf - 1;
int l1 = 1;
@ -1291,8 +1291,8 @@ static void rffti1_ps(int n, float *wa, int *ifac)
for (ii = 3; ii <= ido; ii += 2) {
i += 2;
fi += 1;
wa[i - 2] = cos(fi * argld);
wa[i - 1] = sin(fi * argld);
wa[i - 2] = cosf(fi * argld);
wa[i - 1] = sinf(fi * argld);
}
is += ido;
}
@ -1306,7 +1306,7 @@ static void cffti1_ps(int n, float *wa, int *ifac)
int k1, j, ii;
int nf = decompose(n, ifac, ntryh);
float argh = (2 * M_PI) / (float)n;
float argh = (2 * M_PIf) / (float)n;
int i = 1;
int l1 = 1;
for (k1 = 1; k1 <= nf; k1++) {
@ -1326,8 +1326,8 @@ static void cffti1_ps(int n, float *wa, int *ifac)
for (ii = 4; ii <= idot; ii += 2) {
i += 2;
fi += 1;
wa[i - 1] = cos(fi * argld);
wa[i] = sin(fi * argld);
wa[i - 1] = cosf(fi * argld);
wa[i] = sinf(fi * argld);
}
if (ip > 5) {
wa[i1 - 1] = wa[i - 1];
@ -1440,11 +1440,11 @@ static PFFFT_Setup *new_setup_simd(int N, pffft_transform_t transform)
int i = k / SIMD_SZ;
int j = k % SIMD_SZ;
for (m = 0; m < SIMD_SZ - 1; ++m) {
float A = -2 * M_PI * (m + 1) * k / N;
float A = -2 * M_PIf * (m + 1) * k / N;
s->e[(2 * (i * 3 + m) + 0) * SIMD_SZ + j] =
cos(A);
cosf(A);
s->e[(2 * (i * 3 + m) + 1) * SIMD_SZ + j] =
sin(A);
sinf(A);
}
}
rffti1_ps(N / SIMD_SZ, s->twiddle, s->ifac);
@ -1453,11 +1453,11 @@ static PFFFT_Setup *new_setup_simd(int N, pffft_transform_t transform)
int i = k / SIMD_SZ;
int j = k % SIMD_SZ;
for (m = 0; m < SIMD_SZ - 1; ++m) {
float A = -2 * M_PI * (m + 1) * k / N;
float A = -2 * M_PIf * (m + 1) * k / N;
s->e[(2 * (i * 3 + m) + 0) * SIMD_SZ + j] =
cos(A);
cosf(A);
s->e[(2 * (i * 3 + m) + 1) * SIMD_SZ + j] =
sin(A);
sinf(A);
}
}
cffti1_ps(N / SIMD_SZ, s->twiddle, s->ifac);
@ -1765,7 +1765,7 @@ static NEVER_INLINE(void) pffft_real_finalize(int Ncvec, const v4sf * in,
v4sf_union cr, ci, *uout = (v4sf_union *) out;
v4sf save = in[7], zero = VZERO();
float xr0, xi0, xr1, xi1, xr2, xi2, xr3, xi3;
static const float s = M_SQRT2 / 2;
static const float s = M_SQRT2f / 2;
cr.v = in[0];
ci.v = in[Ncvec * 2 - 1];
@ -1871,7 +1871,7 @@ static NEVER_INLINE(void) pffft_real_preprocess(int Ncvec, const v4sf * in,
v4sf_union Xr, Xi, *uout = (v4sf_union *) out;
float cr0, ci0, cr1, ci1, cr2, ci2, cr3, ci3;
static const float s = M_SQRT2;
static const float s = M_SQRT2f;
assert(in != out);
for (k = 0; k < 4; ++k) {
Xr.f[k] = ((float *)in)[8 * k];

View file

@ -248,7 +248,7 @@ static void capture_destroy(void *d)
static void recalculate_delay(struct impl *impl)
{
uint32_t target = impl->rate * impl->target_delay, cdelay, pdelay;
uint32_t target = (uint32_t)(impl->rate * impl->target_delay), cdelay, pdelay;
uint32_t delay, w;
struct pw_time pwt;
@ -435,7 +435,7 @@ static void param_format_changed(struct impl *impl, const struct spa_pod *param,
static void recalculate_buffer(struct impl *impl)
{
if (impl->target_delay > 0.0f && impl->channels > 0 && impl->rate > 0) {
uint32_t delay = impl->rate * impl->target_delay;
uint32_t delay = (uint32_t)(impl->rate * impl->target_delay);
void *data;
impl->buffer_size = (delay + (1u<<15)) * 4;

View file

@ -199,7 +199,7 @@ struct impl {
struct spa_dll dll;
float max_error;
float corr;
double corr;
uint64_t next_time;
unsigned int have_sync:1;
@ -244,7 +244,7 @@ static void on_timeout(void *d, uint64_t expirations)
pw_log_debug("timeout %"PRIu64, duration);
current_time = impl->next_time;
impl->next_time += duration / impl->corr * 1e9 / rate;
impl->next_time += (uint64_t)(duration / impl->corr * 1e9 / rate);
avail = spa_ringbuffer_get_read_index(&impl->ring, &index);
if (SPA_LIKELY(pos)) {
@ -376,7 +376,7 @@ static void update_rate(struct impl *impl, uint32_t filled)
if (!impl->driving) {
SPA_FLAG_SET(impl->rate_match->flags, SPA_IO_RATE_MATCH_FLAG_ACTIVE);
impl->rate_match->rate = 1.0f / impl->corr;
impl->rate_match->rate = 1.0 / impl->corr;
}
}

View file

@ -868,7 +868,7 @@ int format_info_to_spec(const struct format_info *info, struct sample_spec *ss,
if (spa_json_is_float(val, len)) {
if (spa_json_parse_float(val, len, &f) <= 0)
return -EINVAL;
ss->channels = f;
ss->channels = (uint8_t)f;
} else if (spa_json_is_array(val, len)) {
return -ENOTSUP;
} else if (spa_json_is_object(val, len)) {

View file

@ -636,7 +636,7 @@ int message_put(struct message *m, ...)
write_dict(m, va_arg(va, struct spa_dict*), true);
break;
case TAG_VOLUME:
write_volume(m, va_arg(va, double));
write_volume(m, (float)va_arg(va, double));
break;
case TAG_FORMAT_INFO:
write_format_info(m, va_arg(va, struct format_info*));

View file

@ -4559,7 +4559,7 @@ static int do_update_stream_sample_rate(struct client *client, uint32_t command,
stream->rate = rate;
corr = (double)rate/(double)stream->ss.rate;
corr = (float)rate/(float)stream->ss.rate;
pw_stream_set_control(stream->stream, SPA_PROP_rate, 1, &corr, NULL);
return reply_simple_ack(client, tag);

View file

@ -79,7 +79,7 @@ int volume_parse_param(const struct spa_pod *param, struct volume_info *info, bo
{
float step;
if (spa_pod_get_float(&prop->value, &step) >= 0)
info->steps = 0x10000u * step;
info->steps = (uint32_t)(0x10000u * step);
break;
}
case SPA_PROP_channelMap:

View file

@ -339,7 +339,7 @@ static void update_rate(struct impl *impl, uint32_t filled)
error = (float)impl->target_latency - (float)(current_latency);
error = SPA_CLAMP(error, -impl->max_error, impl->max_error);
corr = spa_dll_update(&impl->dll, error);
corr = (float)spa_dll_update(&impl->dll, error);
pw_log_debug("error:%f corr:%f current:%u target:%u",
error, corr,
current_latency, impl->target_latency);
@ -853,7 +853,7 @@ do_stream_sync_volumes(struct spa_loop *loop,
float soft_vols[SPA_AUDIO_MAX_CHANNELS];
for (i = 0; i < impl->volume.channels; i++) {
vols[i] = pa_sw_volume_to_linear(impl->volume.values[i]);
vols[i] = (float)pa_sw_volume_to_linear(impl->volume.values[i]);
soft_vols[i] = 1.0f;
}

View file

@ -1639,7 +1639,7 @@ static void stream_props_changed(struct impl *impl, uint32_t id, const struct sp
soft_vols[i] = 1.0f;
}
volume /= n_vols;
volume = SPA_CLAMPF(cbrt(volume) * 30 - 30, VOLUME_MIN, VOLUME_MAX);
volume = SPA_CLAMPF(cbrtf(volume) * 30 - 30, VOLUME_MIN, VOLUME_MAX);
impl->volume = volume;
rtsp_send_volume(impl);

View file

@ -66,7 +66,7 @@ static void rtp_audio_process_playback(void *data)
error = (float)target_buffer - (float)avail;
error = SPA_CLAMP(error, -impl->max_error, impl->max_error);
corr = spa_dll_update(&impl->dll, error);
corr = (float)spa_dll_update(&impl->dll, error);
pw_log_trace("avail:%u target:%u error:%f corr:%f", avail,
target_buffer, error, corr);
@ -321,7 +321,7 @@ static void rtp_audio_process_capture(void *data)
uint32_t rate = pos->clock.rate.denom;
timestamp = pos->clock.position * impl->rate / rate;
next_nsec = pos->clock.next_nsec;
quantum = pos->clock.duration * SPA_NSEC_PER_SEC / (rate * pos->clock.rate_diff);
quantum = (uint64_t)(pos->clock.duration * SPA_NSEC_PER_SEC / (rate * pos->clock.rate_diff));
} else {
timestamp = expected_timestamp;
next_nsec = 0;

View file

@ -206,10 +206,10 @@ static int rtp_midi_receive_midi(struct impl *impl, uint8_t *packet, uint32_t ti
}
pw_log_trace("%f %f %f %f", t, estimated, diff, impl->corr);
timestamp = t * impl->rate;
timestamp = (uint32_t)(t * impl->rate);
impl->last_timestamp = ts;
impl->last_time = t;
impl->last_timestamp = (float)ts;
impl->last_time = (float)t;
}
filled = spa_ringbuffer_get_write_index(&impl->ring, &write);
@ -248,7 +248,7 @@ static int rtp_midi_receive_midi(struct impl *impl, uint8_t *packet, uint32_t ti
else
offs += parse_varlen(&packet[offs], end - offs, &delta);
timestamp += delta * impl->corr;
timestamp += (uint32_t)(delta * impl->corr);
spa_pod_builder_control(&b, timestamp, SPA_CONTROL_Midi);
size = get_midi_size(&packet[offs], end - offs);

View file

@ -71,7 +71,7 @@ static void rtp_opus_process_playback(void *data)
error = (float)target_buffer - (float)avail;
error = SPA_CLAMP(error, -impl->max_error, impl->max_error);
corr = spa_dll_update(&impl->dll, error);
corr = (float)spa_dll_update(&impl->dll, error);
pw_log_trace("avail:%u target:%u error:%f corr:%f", avail,
target_buffer, error, corr);

View file

@ -285,7 +285,7 @@ static void parse_audio_info(const struct pw_properties *props, struct spa_audio
static uint32_t msec_to_samples(struct impl *impl, float msec)
{
return msec * impl->rate / 1000;
return (uint32_t)(msec * impl->rate / 1000);
}
static float samples_to_msec(struct impl *impl, uint32_t samples)
{
@ -509,7 +509,7 @@ struct rtp_stream *rtp_stream_new(struct pw_core *core,
/* We're not expecting odd ptimes, so this modulo should be 0 */
if (fmodf(impl->target_buffer, ptime != 0)) {
pw_log_warn("sess.latency.msec should be an integer multiple of rtp.ptime");
impl->target_buffer = (impl->target_buffer / ptime) * impl->psamples;
impl->target_buffer = (uint32_t)((impl->target_buffer / ptime) * impl->psamples);
}
pw_properties_setf(props, PW_KEY_NODE_RATE, "1/%d", impl->rate);

View file

@ -57,7 +57,7 @@ static void vban_audio_process_playback(void *data)
error = (float)target_buffer - (float)avail;
error = SPA_CLAMP(error, -impl->max_error, impl->max_error);
corr = spa_dll_update(&impl->dll, error);
corr = (float)spa_dll_update(&impl->dll, error);
pw_log_debug("avail:%u target:%u error:%f corr:%f", avail,
target_buffer, error, corr);

View file

@ -358,8 +358,8 @@ struct vban_stream *vban_stream_new(struct pw_core *core,
if (!spa_atof(str, &max_ptime))
max_ptime = DEFAULT_MAX_PTIME;
min_samples = min_ptime * impl->rate / 1000;
max_samples = SPA_MIN(256, max_ptime * impl->rate / 1000);
min_samples = (uint32_t)(min_ptime * impl->rate / 1000);
max_samples = SPA_MIN(256u, (uint32_t)(max_ptime * impl->rate / 1000));
float ptime = 0;
if ((str = pw_properties_get(props, "vban.ptime")) != NULL)
@ -367,7 +367,7 @@ struct vban_stream *vban_stream_new(struct pw_core *core,
ptime = 0.0;
if (ptime) {
impl->psamples = ptime * impl->rate / 1000;
impl->psamples = (uint32_t)(ptime * impl->rate / 1000);
} else {
impl->psamples = impl->mtu / impl->stride;
impl->psamples = SPA_CLAMP(impl->psamples, min_samples, max_samples);

View file

@ -1219,11 +1219,11 @@ static int node_event_param(void *object, int seq,
vals = SPA_POD_BODY(pod);
else if (spa_pod_is_double(pod)) {
double *v = SPA_POD_BODY(pod);
dbl[0] = v[0];
dbl[0] = (float)v[0];
if (n_vals > 1)
dbl[1] = v[1];
dbl[1] = (float)v[1];
if (n_vals > 2)
dbl[2] = v[2];
dbl[2] = (float)v[2];
vals = dbl;
}
else if (spa_pod_is_bool(pod) && n_vals > 0) {
@ -1301,7 +1301,7 @@ static int node_event_param(void *object, int seq,
if (spa_pod_get_double(&prop->value, &value_d) < 0)
continue;
n_values = 1;
value_f = value_d;
value_f = (float)value_d;
values = &value_f;
break;
case SPA_TYPE_Bool:
@ -2337,7 +2337,7 @@ int pw_stream_get_time_n(struct pw_stream *stream, struct pw_time *time, size_t
else
time->queued = (int64_t)(impl->queued.incount - time->queued);
time->delay += ((impl->latency.min_quantum + impl->latency.max_quantum) / 2) * quantum;
time->delay += (int64_t)(((impl->latency.min_quantum + impl->latency.max_quantum) / 2.0f) * quantum);
time->delay += (impl->latency.min_rate + impl->latency.max_rate) / 2;
time->delay += ((impl->latency.min_ns + impl->latency.max_ns) / 2) * time->rate.denom / SPA_NSEC_PER_SEC;

View file

@ -215,7 +215,7 @@ endpoint_init(struct endpoint * self)
self->info.params = param_info;
self->info.n_params = SPA_N_ELEMENTS (param_info);
self->props.volume = 0.9;
self->props.volume = 0.9f;
self->props.mute = false;
}

View file

@ -433,7 +433,7 @@ int midi_file_write_event(struct midi_file *mf, const struct midi_event *event)
tr = &mf->tracks[event->track];
tick = event->sec * (1000000.0 * mf->info.division) / (double)mf->tempo;
tick = (uint32_t)(event->sec * (1000000.0 * mf->info.division) / (double)mf->tempo);
CHECK_RES(write_varlen(mf, tr, tick - tr->tick));
tr->tick = tick;

View file

@ -1069,7 +1069,7 @@ static int midi_play(struct data *d, void *src, unsigned int n_frames, bool *nul
return res;
}
frame = ev.sec * d->position->clock.rate.denom;
frame = (uint32_t)(ev.sec * d->position->clock.rate.denom);
if (frame < first_frame)
frame = 0;
else if (frame < last_frame)
@ -1573,13 +1573,13 @@ static int setup_properties(struct data *data)
nom = data->latency_value * data->rate;
break;
case unit_msec:
nom = nearbyint((data->latency_value * data->rate) / 1000.0);
nom = (unsigned int)nearbyint((data->latency_value * data->rate) / 1000.0);
break;
case unit_usec:
nom = nearbyint((data->latency_value * data->rate) / 1000000.0);
nom = (unsigned int)nearbyint((data->latency_value * data->rate) / 1000000.0);
break;
case unit_nsec:
nom = nearbyint((data->latency_value * data->rate) / 1000000000.0);
nom = (unsigned int)nearbyint((data->latency_value * data->rate) / 1000000000.0);
break;
case unit_samples:
nom = data->latency_value;
@ -1778,7 +1778,7 @@ int main(int argc, char *argv[])
break;
case OPT_VOLUME:
data.volume = atof(optarg);
data.volume = (float)atof(optarg);
break;
default:
goto error_usage;

View file

@ -279,7 +279,7 @@ static void put_double(struct data *d, const char *key, double val)
{
char buf[128];
put_fmt(d, key, "%s%s%s", NUMBER,
spa_json_format_float(buf, sizeof(buf), val), NORMAL);
spa_json_format_float(buf, sizeof(buf), (float)val), NORMAL);
}
static void put_value(struct data *d, const char *key, const char *val)

View file

@ -163,7 +163,7 @@ int main(int argc, char *argv[])
data.latency = atoi(optarg) * DEFAULT_RATE / SPA_MSEC_PER_SEC;
break;
case 'd':
data.delay = atof(optarg);
data.delay = (float)atof(optarg);
break;
case 'C':
pw_properties_set(data.capture_props, PW_KEY_TARGET_OBJECT, optarg);

View file

@ -182,8 +182,8 @@ static void dump_point(struct data *d, struct point *point)
int64_t d1, d2;
int64_t delay, period_usecs;
#define CLOCK_AS_USEC(cl,val) (val * (float)SPA_USEC_PER_SEC / (cl)->rate.denom)
#define CLOCK_AS_SUSEC(cl,val) (val * (float)SPA_USEC_PER_SEC / ((cl)->rate.denom * (cl)->rate_diff))
#define CLOCK_AS_USEC(cl,val) (int64_t)(val * (float)SPA_USEC_PER_SEC / (cl)->rate.denom)
#define CLOCK_AS_SUSEC(cl,val) (int64_t)(val * (float)SPA_USEC_PER_SEC / ((cl)->rate.denom * (cl)->rate_diff))
delay = CLOCK_AS_USEC(&point->clock, point->clock.delay);
period_usecs = CLOCK_AS_SUSEC(&point->clock, point->clock.duration);
@ -193,7 +193,7 @@ static void dump_point(struct data *d, struct point *point)
if (d1 > period_usecs * 1.3 ||
d2 > period_usecs * 1.3)
d1 = d2 = period_usecs * 1.4;
d1 = d2 = (int64_t)(period_usecs * 1.4);
/* 4 columns for the driver */
fprintf(d->output, "%"PRIi64"\t%"PRIi64"\t%"PRIi64"\t%"PRIi64"\t",