mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-13 13:30:05 -05:00
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:
parent
50870aac57
commit
1ae4374ccf
71 changed files with 286 additions and 284 deletions
|
|
@ -388,7 +388,7 @@ static int cmd_set_volume(struct data *data, const struct command *cmd, int argc
|
|||
return -EINVAL;
|
||||
}
|
||||
dev_id = atoi(argv[1]);
|
||||
vol = atof(argv[2]);
|
||||
vol = (float)atof(argv[2]);
|
||||
|
||||
if (dev_id >= card->n_devices)
|
||||
return -EINVAL;
|
||||
|
|
@ -418,12 +418,12 @@ static int adjust_volume(struct data *data, const struct command *cmd, int argc,
|
|||
|
||||
static int cmd_inc_volume(struct data *data, const struct command *cmd, int argc, char *argv[])
|
||||
{
|
||||
return adjust_volume(data, cmd, argc, argv, 0.2);
|
||||
return adjust_volume(data, cmd, argc, argv, 0.2f);
|
||||
}
|
||||
|
||||
static int cmd_dec_volume(struct data *data, const struct command *cmd, int argc, char *argv[])
|
||||
{
|
||||
return adjust_volume(data, cmd, argc, argv, -0.2);
|
||||
return adjust_volume(data, cmd, argc, argv, -0.2f);
|
||||
}
|
||||
|
||||
static int cmd_get_mute(struct data *data, const struct command *cmd, int argc, char *argv[])
|
||||
|
|
|
|||
|
|
@ -1335,7 +1335,7 @@ static void mixer_volume_init(pa_card *impl, pa_alsa_device *dev)
|
|||
pa_log_info("Using hardware volume control. Hardware dB scale %s.",
|
||||
dev->mixer_path->has_dB ? "supported" : "not supported");
|
||||
}
|
||||
dev->device.base_volume = pa_sw_volume_to_linear(dev->base_volume);
|
||||
dev->device.base_volume = (float)pa_sw_volume_to_linear(dev->base_volume);
|
||||
dev->device.volume_step = 1.0f / dev->n_volume_steps;
|
||||
|
||||
if (impl->soft_mixer || !dev->mixer_path || !dev->mixer_path->has_mute) {
|
||||
|
|
@ -2022,7 +2022,7 @@ static int get_volume(pa_cvolume *v, float *volume, uint32_t n_volume)
|
|||
if (v->channels == 0)
|
||||
return -EIO;
|
||||
for (i = 0; i < n_volume; i++)
|
||||
volume[i] = pa_sw_volume_to_linear(v->values[i % v->channels]);
|
||||
volume[i] = (float)pa_sw_volume_to_linear(v->values[i % v->channels]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1147,7 +1147,7 @@ static int element_set_volume(pa_alsa_element *e, snd_mixer_t *m, const pa_chann
|
|||
int rounding;
|
||||
|
||||
if (e->volume_limit >= 0 && value > (e->max_dB * 100))
|
||||
value = e->max_dB * 100;
|
||||
value = (long) (e->max_dB * 100);
|
||||
|
||||
if (e->direction == PA_ALSA_DIRECTION_OUTPUT) {
|
||||
/* If we call set_playback_volume() without checking first
|
||||
|
|
|
|||
|
|
@ -1206,7 +1206,7 @@ static unsigned devset_playback_priority(pa_idxset *devices, bool invert) {
|
|||
}
|
||||
|
||||
if (priority > 0 && invert)
|
||||
return 1.0 / priority;
|
||||
return (unsigned)(1.0 / priority);
|
||||
|
||||
return (unsigned) priority;
|
||||
}
|
||||
|
|
@ -1224,7 +1224,7 @@ static unsigned devset_capture_priority(pa_idxset *devices, bool invert) {
|
|||
}
|
||||
|
||||
if (priority > 0 && invert)
|
||||
return 1.0 / priority;
|
||||
return (unsigned)(1.0 / priority);
|
||||
|
||||
return (unsigned) priority;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2283,11 +2283,11 @@ int spa_alsa_update_rate_match(struct state *state)
|
|||
* means that to adjust the playback rate, we need to apply the inverse
|
||||
* of the given rate. */
|
||||
if (state->stream == SND_PCM_STREAM_CAPTURE) {
|
||||
pitch = 1000000 * state->rate_match->rate;
|
||||
last_pitch = 1000000 * state->last_rate;
|
||||
pitch = (uint64_t)(1000000 * state->rate_match->rate);
|
||||
last_pitch = (uint64_t)(1000000 * state->last_rate);
|
||||
} else {
|
||||
pitch = 1000000 / state->rate_match->rate;
|
||||
last_pitch = 1000000 / state->last_rate;
|
||||
pitch = (uint64_t)(1000000 / state->rate_match->rate);
|
||||
last_pitch = (uint64_t)(1000000 / state->last_rate);
|
||||
}
|
||||
|
||||
/* The pitch adjustment is limited to 1 ppm */
|
||||
|
|
@ -2727,7 +2727,7 @@ static int update_time(struct state *state, uint64_t current_time, snd_pcm_sfram
|
|||
corr = 1.0;
|
||||
|
||||
if (diff < 0)
|
||||
state->next_time += diff / corr * 1e9 / state->rate;
|
||||
state->next_time += (uint64_t)(diff / corr * 1e9 / state->rate);
|
||||
|
||||
if (SPA_UNLIKELY((state->next_time - state->base_time) > BW_PERIOD)) {
|
||||
state->base_time = state->next_time;
|
||||
|
|
@ -2751,7 +2751,7 @@ static int update_time(struct state *state, uint64_t current_time, snd_pcm_sfram
|
|||
SPA_FLAG_UPDATE(state->rate_match->flags, SPA_IO_RATE_MATCH_FLAG_ACTIVE, state->matching);
|
||||
}
|
||||
|
||||
state->next_time += state->threshold / corr * 1e9 / state->rate;
|
||||
state->next_time += (uint64_t)(state->threshold / corr * 1e9 / state->rate);
|
||||
|
||||
if (SPA_LIKELY(!follower && state->clock)) {
|
||||
state->clock->nsec = current_time;
|
||||
|
|
@ -2859,7 +2859,7 @@ static int alsa_write_sync(struct state *state, uint64_t current_time)
|
|||
|
||||
if (SPA_UNLIKELY((res = get_status(state, current_time, &avail, &delay, &target)) < 0)) {
|
||||
spa_log_error(state->log, "get_status error: %s", spa_strerror(res));
|
||||
state->next_time += state->threshold * 1e9 / state->rate;
|
||||
state->next_time += (uint64_t)(state->threshold * 1e9 / state->rate);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
|
@ -3120,7 +3120,7 @@ static int alsa_read_sync(struct state *state, uint64_t current_time)
|
|||
|
||||
if (SPA_UNLIKELY((res = get_status(state, current_time, &avail, &delay, &target)) < 0)) {
|
||||
spa_log_error(state->log, "get_status error: %s", spa_strerror(res));
|
||||
state->next_time += state->threshold * 1e9 / state->rate;
|
||||
state->next_time += (uint64_t)(state->threshold * 1e9 / state->rate);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
|
@ -3442,7 +3442,7 @@ static void alsa_timer_wakeup_event(struct spa_source *source)
|
|||
state->next_time - current_time, state->threshold,
|
||||
state->sample_count, suppressed);
|
||||
}
|
||||
state->next_time = current_time + state->threshold * 1e9 / state->rate;
|
||||
state->next_time = (uint64_t)(current_time + state->threshold * 1e9 / state->rate);
|
||||
}
|
||||
set_timeout(state, state->next_time);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -797,9 +797,9 @@ static int update_time(struct seq_state *state, uint64_t nsec, bool follower)
|
|||
* use the rate correction, else we will use the rate correction only for the new
|
||||
* timeout. */
|
||||
if (state->following)
|
||||
state->queue_next += state->threshold * corr * 1e9 / state->rate.denom;
|
||||
state->queue_next += (uint64_t)(state->threshold * corr * 1e9 / state->rate.denom);
|
||||
else
|
||||
state->queue_next += state->threshold * 1e9 / state->rate.denom;
|
||||
state->queue_next += (uint64_t)(state->threshold * 1e9 / state->rate.denom);
|
||||
|
||||
if ((state->next_time - state->base_time) > BW_PERIOD) {
|
||||
state->base_time = state->next_time;
|
||||
|
|
@ -807,14 +807,14 @@ static int update_time(struct seq_state *state, uint64_t nsec, bool follower)
|
|||
state, follower, corr, state->dll.bw, err,
|
||||
state->dll.z1, state->dll.z2, state->dll.z3);
|
||||
}
|
||||
state->next_time += state->threshold / corr * 1e9 / state->rate.denom;
|
||||
state->next_time += (uint64_t)(state->threshold / corr * 1e9 / state->rate.denom);
|
||||
|
||||
if (!follower && state->clock) {
|
||||
state->clock->nsec = nsec;
|
||||
state->clock->rate = state->rate;
|
||||
state->clock->position += state->clock->duration;
|
||||
state->clock->duration = state->duration;
|
||||
state->clock->delay = state->duration * corr;
|
||||
state->clock->delay = (int64_t)(state->duration * corr);
|
||||
state->clock->rate_diff = corr;
|
||||
state->clock->next_nsec = state->next_time;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
#define DEFAULT_DEVICE "hw:0"
|
||||
|
||||
#define M_PI_M2 (M_PI + M_PI)
|
||||
#define M_PI_M2f (M_PIf + M_PIf)
|
||||
|
||||
#define BW_PERIOD (SPA_NSEC_PER_SEC * 3)
|
||||
|
||||
|
|
@ -63,10 +63,10 @@ static int set_timeout(struct state *state, uint64_t time)
|
|||
type *samples, v; \
|
||||
samples = (type*)((uint8_t*)areas[0].addr + (areas[0].first + offset*areas[0].step) / 8); \
|
||||
for (i = 0; i < frames; i++) { \
|
||||
state->accumulator += M_PI_M2 * 440 / state->rate; \
|
||||
if (state->accumulator >= M_PI_M2) \
|
||||
state->accumulator -= M_PI_M2; \
|
||||
v = sin(state->accumulator) * scale; \
|
||||
state->accumulator += M_PI_M2f * 440.0f / state->rate; \
|
||||
if (state->accumulator >= M_PI_M2f) \
|
||||
state->accumulator -= M_PI_M2f; \
|
||||
v = (type)(sin(state->accumulator) * scale); \
|
||||
for (j = 0; j < state->channels; j++) \
|
||||
*samples++ = v; \
|
||||
} \
|
||||
|
|
@ -135,7 +135,7 @@ static int on_timer_wakeup(struct state *state)
|
|||
/* set our new adjusted timeout. alternatively, this value can
|
||||
* instead be used to drive a resampler if this device is
|
||||
* slaved. */
|
||||
state->next_time += state->period / corr * 1e9 / state->rate;
|
||||
state->next_time += (uint64_t)(state->period / corr * 1e9 / state->rate);
|
||||
set_timeout(state, state->next_time);
|
||||
|
||||
if (state->next_time - state->prev_time > BW_PERIOD) {
|
||||
|
|
|
|||
|
|
@ -26,11 +26,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)
|
||||
|
|
|
|||
|
|
@ -649,7 +649,7 @@ done:
|
|||
spa_debug_type_find_short_name(spa_type_audio_channel, j + _SH));
|
||||
|
||||
mix->matrix_orig[ic][jc++] = matrix[i][j];
|
||||
sum += fabs(matrix[i][j]);
|
||||
sum += fabsf(matrix[i][j]);
|
||||
|
||||
if (matrix[i][j] == 0.0f)
|
||||
spa_strbuf_append(&sb1, " ");
|
||||
|
|
@ -772,7 +772,7 @@ int channelmix_init(struct channelmix *mix)
|
|||
mix->process = info->process;
|
||||
mix->set_volume = impl_channelmix_set_volume;
|
||||
mix->cpu_flags = info->cpu_flags;
|
||||
mix->delay = mix->rear_delay * mix->freq / 1000.0f;
|
||||
mix->delay = (uint32_t)(mix->rear_delay * mix->freq / 1000.0f);
|
||||
mix->func_name = info->name;
|
||||
|
||||
spa_log_debug(mix->log, "selected %s delay:%d options:%08x", info->name, mix->delay,
|
||||
|
|
|
|||
|
|
@ -969,7 +969,8 @@ conv_deinterleave_32s_1s_sse2(void *data, void * SPA_RESTRICT dst[], const void
|
|||
s += 4*n_channels;
|
||||
}
|
||||
for(; n < n_samples; n++) {
|
||||
d0[n] = bswap_32(*s);
|
||||
uint32_t *di = (uint32_t*)&d0[n], *si = (uint32_t*)s;
|
||||
*di = bswap_32(*si);
|
||||
s += n_channels;
|
||||
}
|
||||
}
|
||||
|
|
@ -1011,10 +1012,10 @@ conv_deinterleave_32s_4s_sse2(void *data, void * SPA_RESTRICT dst[], const void
|
|||
s += 4 * n_channels;
|
||||
}
|
||||
for(; n < n_samples; n++) {
|
||||
d0[n] = bswap_32(s[0]);
|
||||
d1[n] = bswap_32(s[1]);
|
||||
d2[n] = bswap_32(s[2]);
|
||||
d3[n] = bswap_32(s[3]);
|
||||
*((uint32_t*)&d0[n]) = bswap_32(*((uint32_t*)&s[0]));
|
||||
*((uint32_t*)&d1[n]) = bswap_32(*((uint32_t*)&s[1]));
|
||||
*((uint32_t*)&d2[n]) = bswap_32(*((uint32_t*)&s[2]));
|
||||
*((uint32_t*)&d3[n]) = bswap_32(*((uint32_t*)&s[3]));
|
||||
s += n_channels;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,9 +17,9 @@ static inline void blackman_window(float *taps, int n_taps)
|
|||
{
|
||||
int n;
|
||||
for (n = 0; n < n_taps; n++) {
|
||||
float w = 2 * M_PI * n / (n_taps-1);
|
||||
taps[n] = 0.3635819 - 0.4891775 * cos(w)
|
||||
+ 0.1365995 * cos(2 * w) - 0.0106411 * cos(3 * w);
|
||||
float w = 2.0f * M_PIf * n / (n_taps-1);
|
||||
taps[n] = 0.3635819f - 0.4891775f * cosf(w)
|
||||
+ 0.1365995f * cosf(2 * w) - 0.0106411f * cosf(3 * w);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -33,7 +33,7 @@ static inline int hilbert_generate(float *taps, int n_taps)
|
|||
for (i = 0; i < n_taps; i++) {
|
||||
int k = -(n_taps / 2) + i;
|
||||
if (k & 1) {
|
||||
float pk = M_PI * k;
|
||||
float pk = M_PIf * k;
|
||||
taps[i] *= (1.0f - cosf(pk)) / pk;
|
||||
} else {
|
||||
taps[i] = 0.0f;
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@ DEFINE_RESAMPLER(full,arch) \
|
|||
float *d = dst[c]; \
|
||||
\
|
||||
index = ioffs; \
|
||||
phase = data->phase; \
|
||||
phase = (uint32_t)data->phase; \
|
||||
\
|
||||
for (o = ooffs; o < olen && index + n_taps <= ilen; o++) { \
|
||||
inner_product_##arch(&d[o], &s[index], \
|
||||
|
|
@ -117,12 +117,12 @@ DEFINE_RESAMPLER(full,arch) \
|
|||
DEFINE_RESAMPLER(inter,arch) \
|
||||
{ \
|
||||
struct native_data *data = r->data; \
|
||||
uint32_t index, stride = data->filter_stride; \
|
||||
uint32_t index, stride = data->filter_stride; \
|
||||
uint32_t n_phases = data->n_phases, out_rate = data->out_rate; \
|
||||
uint32_t n_taps = data->n_taps; \
|
||||
uint32_t c, o, olen = *out_len, ilen = *in_len; \
|
||||
uint32_t inc = data->inc, frac = data->frac; \
|
||||
float phase; \
|
||||
float phase; \
|
||||
\
|
||||
if (r->channels == 0) \
|
||||
return; \
|
||||
|
|
@ -135,8 +135,8 @@ DEFINE_RESAMPLER(inter,arch) \
|
|||
phase = data->phase; \
|
||||
\
|
||||
for (o = ooffs; o < olen && index + n_taps <= ilen; o++) { \
|
||||
float ph = phase * n_phases / out_rate; \
|
||||
uint32_t offset = floorf(ph); \
|
||||
float ph = phase * n_phases / out_rate; \
|
||||
uint32_t offset = (uint32_t)floorf(ph); \
|
||||
inner_product_ip_##arch(&d[o], &s[index], \
|
||||
&data->filter[(offset + 0) * stride], \
|
||||
&data->filter[(offset + 1) * stride], \
|
||||
|
|
|
|||
|
|
@ -72,8 +72,8 @@ static int build_filter(float *taps, uint32_t stride, uint32_t n_taps, uint32_t
|
|||
for (j = 0; j < n_taps12; j++, t += 1.0) {
|
||||
/* exploit symmetry in filter taps */
|
||||
taps[(n_phases - i) * stride + n_taps12 + j] =
|
||||
taps[i * stride + (n_taps12 - j - 1)] =
|
||||
cutoff * sinc(t * cutoff) * window(t, n_taps);
|
||||
taps[i * stride + (n_taps12 - j - 1)] = (float)
|
||||
(cutoff * sinc(t * cutoff) * window(t, n_taps));
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -141,7 +141,7 @@ static void impl_native_update_rate(struct resample *r, double rate)
|
|||
return;
|
||||
|
||||
old_out_rate = data->out_rate;
|
||||
in_rate = r->i_rate / rate;
|
||||
in_rate = (uint32_t)(r->i_rate / rate);
|
||||
out_rate = r->o_rate;
|
||||
phase = data->phase;
|
||||
|
||||
|
|
@ -180,7 +180,7 @@ static uint32_t impl_native_in_len(struct resample *r, uint32_t out_len)
|
|||
struct native_data *data = r->data;
|
||||
uint32_t in_len;
|
||||
|
||||
in_len = (data->phase + out_len * data->frac) / data->out_rate;
|
||||
in_len = (uint32_t)((data->phase + out_len * data->frac) / data->out_rate);
|
||||
in_len += out_len * data->inc + (data->n_taps - data->hist);
|
||||
|
||||
spa_log_trace_fp(r->log, "native %p: hist:%d %d->%d", r, data->hist, out_len, in_len);
|
||||
|
|
@ -194,7 +194,7 @@ static uint32_t impl_native_out_len(struct resample *r, uint32_t in_len)
|
|||
uint32_t out_len;
|
||||
|
||||
in_len = in_len - SPA_MIN(in_len, (data->n_taps - data->hist) + 1);
|
||||
out_len = in_len * data->out_rate - data->phase;
|
||||
out_len = (uint32_t)(in_len * data->out_rate - data->phase);
|
||||
out_len = (out_len + data->in_rate - 1) / data->in_rate;
|
||||
|
||||
spa_log_trace_fp(r->log, "native %p: hist:%d %d->%d", r, data->hist, in_len, out_len);
|
||||
|
|
|
|||
|
|
@ -18,14 +18,14 @@ static uint32_t cpu_flags;
|
|||
|
||||
SPA_LOG_IMPL(logger);
|
||||
|
||||
#define MATRIX(...) (float[]) { __VA_ARGS__ }
|
||||
#define MATRIX(...) (double[]) { __VA_ARGS__ }
|
||||
|
||||
#include "test-helper.h"
|
||||
#include "channelmix-ops.c"
|
||||
|
||||
#define CLOSE_ENOUGH(a,b) (fabs((a)-(b)) < 0.000001f)
|
||||
|
||||
static void dump_matrix(struct channelmix *mix, float *coeff)
|
||||
static void dump_matrix(struct channelmix *mix, double *coeff)
|
||||
{
|
||||
uint32_t i, j;
|
||||
|
||||
|
|
@ -33,13 +33,13 @@ static void dump_matrix(struct channelmix *mix, float *coeff)
|
|||
for (j = 0; j < mix->src_chan; j++) {
|
||||
float v = mix->matrix[i][j];
|
||||
spa_log_debug(mix->log, "%d %d: %f <-> %f", i, j, v, *coeff);
|
||||
spa_assert_se(CLOSE_ENOUGH(v, *coeff));
|
||||
spa_assert_se(CLOSE_ENOUGH(v, (float)*coeff));
|
||||
coeff++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void test_mix(uint32_t src_chan, uint32_t src_mask, uint32_t dst_chan, uint32_t dst_mask, uint32_t options, float *coeff)
|
||||
static void test_mix(uint32_t src_chan, uint32_t src_mask, uint32_t dst_chan, uint32_t dst_mask, uint32_t options, double *coeff)
|
||||
{
|
||||
struct channelmix mix;
|
||||
|
||||
|
|
@ -336,7 +336,7 @@ static void test_n_m_impl(void)
|
|||
|
||||
for (i = 0; i < 16; i++) {
|
||||
for (j = 0; j < N_SAMPLES; j++)
|
||||
src_data[i][j] = (drand48() - 0.5f) * 2.5f;
|
||||
src_data[i][j] = (float)((drand48() - 0.5f) * 2.5f);
|
||||
src[i] = src_data[i];
|
||||
}
|
||||
|
||||
|
|
@ -360,7 +360,7 @@ static void test_n_m_impl(void)
|
|||
/* random matrix */
|
||||
for (i = 0; i < mix.dst_chan; i++) {
|
||||
for (j = 0; j < mix.src_chan; j++) {
|
||||
mix.matrix_orig[i][j] = drand48() - 0.5f;
|
||||
mix.matrix_orig[i][j] = (float)(drand48() - 0.5f);
|
||||
}
|
||||
}
|
||||
channelmix_set_volume(&mix, 1.0f, false, 0, NULL);
|
||||
|
|
|
|||
|
|
@ -321,7 +321,7 @@ static void test_f32_s32(void)
|
|||
static void test_s32_f32(void)
|
||||
{
|
||||
static const int32_t in[] = { 0, 0x7fffff00, 0x80000000, 0x40000000, 0xc0000000 };
|
||||
static const float out[] = { 0.0f, 0.999999880791, -1.0f, 0.5, -0.5, };
|
||||
static const float out[] = { 0.0f, 0.999999880791f, -1.0f, 0.5, -0.5, };
|
||||
|
||||
run_test("test_s32_f32d", in, sizeof(in[0]), out, sizeof(out[0]), SPA_N_ELEMENTS(out),
|
||||
true, false, conv_s32_to_f32d_c);
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ static void test_impl(void)
|
|||
float min[2] = { 0.0f, 0.0f }, max[2] = { 0.0f, 0.0f }, absmax[2] = { 0.0f, 0.0f };
|
||||
|
||||
for (i = 0; i < SPA_N_ELEMENTS(vals); i++)
|
||||
vals[i] = (drand48() - 0.5f) * 2.5f;
|
||||
vals[i] = (float)((drand48() - 0.5f) * 2.5f);
|
||||
|
||||
peaks_min_max_c(&peaks, &vals[1], SPA_N_ELEMENTS(vals) - 1, &min[0], &max[0]);
|
||||
printf("c peaks min:%f max:%f\n", min[0], max[0]);
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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 */
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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 ||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -318,7 +318,7 @@ static inline uint64_t scale_u64(uint64_t val, uint32_t num, uint32_t denom)
|
|||
#if 0
|
||||
return ((__uint128_t)val * num) / denom;
|
||||
#else
|
||||
return (double)val / denom * num;
|
||||
return (uint64_t)((double)val / denom * num);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
@ -390,7 +390,7 @@ static void on_timeout(struct spa_source *source)
|
|||
}
|
||||
}
|
||||
corr = spa_dll_update(&this->dll, err);
|
||||
this->next_time = nsec + duration / corr * 1e9 / rate;
|
||||
this->next_time = (uint64_t)(nsec + duration / corr * 1e9 / rate);
|
||||
} else {
|
||||
corr = 1.0;
|
||||
this->next_time = scale_u64(position + duration, SPA_NSEC_PER_SEC, rate);
|
||||
|
|
@ -710,7 +710,7 @@ impl_init(const struct spa_handle_factory *factory,
|
|||
} else if (spa_streq(k, "freewheel.wait")) {
|
||||
this->props.freewheel_wait = atoi(s);
|
||||
} else if (spa_streq(k, "resync.ms")) {
|
||||
this->props.resync_ms = atof(s);
|
||||
this->props.resync_ms = (float)atof(s);
|
||||
}
|
||||
}
|
||||
if (this->props.clock_name[0] == '\0') {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue