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

@ -246,7 +246,7 @@ static int rfcomm_new_transport(struct rfcomm *rfcomm)
t->volumes[i].active = rfcomm->volumes[i].active;
t->volumes[i].hw_volume_max = SPA_BT_VOLUME_HS_MAX;
if (rfcomm->volumes[i].active && rfcomm->volumes[i].hw_volume != SPA_BT_VOLUME_INVALID)
t->volumes[i].volume =
t->volumes[i].volume = (float)
spa_bt_volume_hw_to_linear(rfcomm->volumes[i].hw_volume, t->volumes[i].hw_volume_max);
}
@ -424,7 +424,7 @@ static void rfcomm_emit_volume_changed(struct rfcomm *rfcomm, int id, int hw_vol
for (int i = 0; i < SPA_BT_VOLUME_ID_TERM ; ++i) {
t_volume = &rfcomm->transport->volumes[i];
t_volume->active = rfcomm->volumes[i].active;
t_volume->volume =
t_volume->volume = (float)
spa_bt_volume_hw_to_linear(rfcomm->volumes[i].hw_volume, t_volume->hw_volume_max);
}

View file

@ -3172,7 +3172,7 @@ static void spa_bt_transport_volume_changed(struct spa_bt_transport *transport)
if (t_volume->hw_volume != t_volume->new_hw_volume) {
t_volume->hw_volume = t_volume->new_hw_volume;
t_volume->volume = spa_bt_volume_hw_to_linear(t_volume->hw_volume,
t_volume->volume = (float)spa_bt_volume_hw_to_linear(t_volume->hw_volume,
t_volume->hw_volume_max);
spa_log_debug(monitor->log, "transport %p: volume changed %d(%f) ",
transport, t_volume->new_hw_volume, t_volume->volume);

View file

@ -581,7 +581,7 @@ static void emit_device_set_node(struct impl *this, uint32_t id)
for (i = 0; i < node->n_channels; ++i) {
/* Session manager will override this, so put in some safe number */
node->volumes[i] = node->soft_volumes[i] = 0.064;
node->volumes[i] = node->soft_volumes[i] = 0.064f;
}
/* Produce member info json */

View file

@ -253,7 +253,7 @@ static void spa_bt_decode_buffer_process(struct spa_bt_decode_buffer *this, uint
level = SPA_MAX(level, -max_level);
this->prev_consumed = SPA_MIN(this->prev_consumed, avg_period);
spa_bt_ptp_update(&this->spike, this->ctl.avg - level, this->prev_consumed);
spa_bt_ptp_update(&this->spike, (int32_t)(this->ctl.avg - level), this->prev_consumed);
/* Update target level */
if (this->target)

View file

@ -1045,7 +1045,7 @@ static void media_iso_pull(struct spa_bt_iso_io *iso_io)
max_err = iso_io->duration;
if (iso_io->resync && err >= 0) {
unsigned int req = err * port->current_format.info.raw.rate / SPA_NSEC_PER_SEC;
unsigned int req = (unsigned int)(err * port->current_format.info.raw.rate / SPA_NSEC_PER_SEC);
if (req > 0) {
spa_bt_rate_control_init(&port->ratectl, 0);
@ -1053,7 +1053,7 @@ static void media_iso_pull(struct spa_bt_iso_io *iso_io)
}
spa_log_debug(this->log, "%p: ISO sync skip frames:%u", this, req);
} else if (iso_io->resync && -err >= 0) {
unsigned int req = -err * port->current_format.info.raw.rate / SPA_NSEC_PER_SEC;
unsigned int req = (unsigned int)(-err * port->current_format.info.raw.rate / SPA_NSEC_PER_SEC);
static const uint8_t empty[8192] = {0};
if (req > 0) {
@ -1172,7 +1172,7 @@ static void media_on_timeout(struct spa_source *source)
setup_matching(this);
this->next_time = now_time + duration * SPA_NSEC_PER_SEC / rate * port->ratectl.corr;
this->next_time = (uint64_t)(now_time + duration * SPA_NSEC_PER_SEC / rate * port->ratectl.corr);
if (SPA_LIKELY(this->clock)) {
this->clock->nsec = now_time;

View file

@ -620,7 +620,7 @@ static void media_on_timeout(struct spa_source *source)
setup_matching(this);
this->next_time = now_time + duration * SPA_NSEC_PER_SEC / port->buffer.corr / rate;
this->next_time = (uint64_t)(now_time + duration * SPA_NSEC_PER_SEC / port->buffer.corr / rate);
if (SPA_LIKELY(this->clock)) {
this->clock->nsec = now_time;

View file

@ -598,7 +598,7 @@ again:
-SPA_CLAMP(err_nsec, -20*SPA_NSEC_PER_MSEC, 20*SPA_NSEC_PER_MSEC)
* this->rate / SPA_NSEC_PER_SEC);
tcorr = SPA_MIN(device_elapsed, SPA_NSEC_PER_SEC) * (corr - 1);
sync->device_time += tcorr;
sync->device_time += (uint64_t)tcorr;
/* reset if too much off */
if (err_nsec < -50 * SPA_NSEC_PER_MSEC ||

View file

@ -667,7 +667,7 @@ static void sco_on_timeout(struct spa_source *source)
setup_matching(this);
this->next_time = now_time + duration * SPA_NSEC_PER_SEC / port->buffer.corr / rate;
this->next_time = (uint64_t)(now_time + duration * SPA_NSEC_PER_SEC / port->buffer.corr / rate);
if (SPA_LIKELY(this->clock)) {
this->clock->nsec = now_time;