mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-29 05:40:27 -04:00
Merge branch 'fixbugs' into 'master'
Miscellaneous minor fixes See merge request pipewire/pipewire!2575
This commit is contained in:
commit
fa1f3164f1
6 changed files with 36 additions and 63 deletions
|
|
@ -118,8 +118,8 @@ cc_flags = common_flags + [
|
|||
'-DSPA_AUDIO_MAX_CHANNELS=128u',
|
||||
]
|
||||
add_project_arguments(cc.get_supported_arguments(cc_flags), language: 'c')
|
||||
|
||||
cc_flags_native = cc_native.get_supported_arguments(cc_flags)
|
||||
add_project_arguments(cc_native.get_supported_arguments(cc_flags),
|
||||
language: 'c', native: true)
|
||||
|
||||
have_cpp = add_languages('cpp', native: false, required : false)
|
||||
|
||||
|
|
|
|||
|
|
@ -578,7 +578,7 @@ static int make_nodes(struct data *data)
|
|||
SPA_PARAM_PORT_CONFIG_direction, SPA_POD_Id(SPA_DIRECTION_OUTPUT),
|
||||
SPA_PARAM_PORT_CONFIG_mode, SPA_POD_Id(SPA_PARAM_PORT_CONFIG_MODE_dsp),
|
||||
SPA_PARAM_PORT_CONFIG_format, SPA_POD_Pod(param));
|
||||
if ((res = spa_node_set_param(data->source_node, SPA_PARAM_PortConfig, 0, param) < 0)) {
|
||||
if ((res = spa_node_set_param(data->source_node, SPA_PARAM_PortConfig, 0, param)) < 0) {
|
||||
printf("can't setup source node %d\n", res);
|
||||
return res;
|
||||
}
|
||||
|
|
@ -647,7 +647,7 @@ static int make_nodes(struct data *data)
|
|||
SPA_PARAM_PORT_CONFIG_format, SPA_POD_Pod(param));
|
||||
|
||||
|
||||
if ((res = spa_node_set_param(data->sink_node, SPA_PARAM_PortConfig, 0, param) < 0)) {
|
||||
if ((res = spa_node_set_param(data->sink_node, SPA_PARAM_PortConfig, 0, param)) < 0) {
|
||||
printf("can't setup sink node %d\n", res);
|
||||
return res;
|
||||
}
|
||||
|
|
@ -987,7 +987,7 @@ int main(int argc, char *argv[])
|
|||
|
||||
setlocale(LC_ALL, "");
|
||||
|
||||
while ((c = getopt_long(argc, argv, "hdmstiac:", long_options, NULL)) != -1) {
|
||||
while ((c = getopt_long(argc, argv, "hd:m:s:t:i:a:c:", long_options, NULL)) != -1) {
|
||||
switch (c) {
|
||||
case 'h':
|
||||
show_help(&data, argv[0], false);
|
||||
|
|
|
|||
|
|
@ -773,7 +773,7 @@ static void bind_ctl_event(struct spa_source *source)
|
|||
snd_ctl_elem_id_alloca(&bound_id);
|
||||
snd_ctl_elem_value_alloca(&old_value);
|
||||
|
||||
while ((err = snd_ctl_read(state->ctl, ev) > 0)) {
|
||||
while ((err = snd_ctl_read(state->ctl, ev)) > 0) {
|
||||
bool changed = false;
|
||||
|
||||
if (snd_ctl_event_get_type(ev) != SND_CTL_EVENT_ELEM)
|
||||
|
|
|
|||
|
|
@ -1538,8 +1538,6 @@ static int get_ramp_samples(struct impl *this, struct volume_ramp_params *vrp)
|
|||
samples = (vrp->volume_ramp_time * vrp->rate) / 1000;
|
||||
spa_log_info(this->log, "volume ramp samples calculated from time is %d", samples);
|
||||
}
|
||||
if (!samples)
|
||||
samples = -1;
|
||||
return samples;
|
||||
}
|
||||
|
||||
|
|
@ -1550,12 +1548,10 @@ static int get_ramp_step_samples(struct impl *this, struct volume_ramp_params *v
|
|||
if (vrp->volume_ramp_step_samples)
|
||||
samples = vrp->volume_ramp_step_samples;
|
||||
else if (vrp->volume_ramp_step_time) {
|
||||
/* convert the step time which is in nano seconds to seconds */
|
||||
samples = (vrp->volume_ramp_step_time/1000) * (vrp->rate/1000);
|
||||
/* convert the step time which is in nano seconds to seconds, round up */
|
||||
samples = SPA_MAX(1u, vrp->volume_ramp_step_time/1000) * (vrp->rate/1000);
|
||||
spa_log_debug(this->log, "volume ramp step samples calculated from time is %d", samples);
|
||||
}
|
||||
if (!samples)
|
||||
samples = -1;
|
||||
return samples;
|
||||
}
|
||||
|
||||
|
|
@ -1568,76 +1564,52 @@ static float get_volume_at_scale(struct volume_ramp_params *vrp, float value)
|
|||
return 0.0;
|
||||
}
|
||||
|
||||
static struct spa_pod *generate_ramp_up_seq(struct impl *this, struct volume_ramp_params *vrp,
|
||||
static struct spa_pod *generate_ramp_seq(struct impl *this, struct volume_ramp_params *vrp,
|
||||
void *buffer, size_t size)
|
||||
{
|
||||
struct spa_pod_dynamic_builder b;
|
||||
struct spa_pod_frame f[1];
|
||||
float start = vrp->start, end = vrp->end, volume_accum = start;
|
||||
int ramp_samples = get_ramp_samples(this, vrp);
|
||||
int ramp_step_samples = get_ramp_step_samples(this, vrp);
|
||||
float volume_step = ((end - start) / (ramp_samples / ramp_step_samples));
|
||||
uint32_t volume_offs = 0;
|
||||
float start = vrp->start, end = vrp->end;
|
||||
int samples = get_ramp_samples(this, vrp);
|
||||
int step = get_ramp_step_samples(this, vrp);
|
||||
int offs = 0;
|
||||
|
||||
if (samples < 0 || step < 0 || (samples > 0 && step == 0))
|
||||
return NULL;
|
||||
|
||||
spa_pod_dynamic_builder_init(&b, buffer, size, 4096);
|
||||
|
||||
spa_pod_builder_push_sequence(&b.b, &f[0], 0);
|
||||
spa_log_info(this->log, "generating ramp up sequence from %f to %f with a"
|
||||
" step value %f at scale %d", start, end, volume_step, vrp->scale);
|
||||
do {
|
||||
float vas = get_volume_at_scale(vrp, volume_accum);
|
||||
spa_log_trace(this->log, "volume accum %f", vas);
|
||||
spa_pod_builder_control(&b.b, volume_offs, SPA_CONTROL_Properties);
|
||||
spa_pod_builder_add_object(&b.b,
|
||||
SPA_TYPE_OBJECT_Props, 0,
|
||||
SPA_PROP_volume, SPA_POD_Float(vas));
|
||||
volume_accum += volume_step;
|
||||
volume_offs += ramp_step_samples;
|
||||
} while (volume_accum < end);
|
||||
return spa_pod_builder_pop(&b.b, &f[0]);
|
||||
}
|
||||
spa_log_info(this->log, "generating ramp sequence from %f to %f with "
|
||||
"step %d/%d at scale %d", start, end, step, samples, vrp->scale);
|
||||
|
||||
static struct spa_pod *generate_ramp_down_seq(struct impl *this, struct volume_ramp_params *vrp,
|
||||
void *buffer, size_t size)
|
||||
{
|
||||
struct spa_pod_dynamic_builder b;
|
||||
struct spa_pod_frame f[1];
|
||||
int ramp_samples = get_ramp_samples(this, vrp);
|
||||
int ramp_step_samples = get_ramp_step_samples(this, vrp);
|
||||
float start = vrp->start, end = vrp->end, volume_accum = start;
|
||||
float volume_step = ((start - end) / (ramp_samples / ramp_step_samples));
|
||||
uint32_t volume_offs = 0;
|
||||
while (1) {
|
||||
float pos = (samples == 0) ? end :
|
||||
SPA_CLAMP(start + (end - start) * offs / samples,
|
||||
SPA_MIN(start, end), SPA_MAX(start, end));
|
||||
float vas = get_volume_at_scale(vrp, pos);
|
||||
|
||||
spa_pod_dynamic_builder_init(&b, buffer, size, 4096);
|
||||
|
||||
spa_pod_builder_push_sequence(&b.b, &f[0], 0);
|
||||
spa_log_info(this->log, "generating ramp down sequence from %f to %f with a"
|
||||
" step value %f at scale %d", start, end, volume_step, vrp->scale);
|
||||
do {
|
||||
float vas = get_volume_at_scale(vrp, volume_accum);
|
||||
spa_log_trace(this->log, "volume accum %f", vas);
|
||||
spa_pod_builder_control(&b.b, volume_offs, SPA_CONTROL_Properties);
|
||||
spa_log_trace(this->log, "volume %d accum %f", offs, vas);
|
||||
spa_pod_builder_control(&b.b, offs, SPA_CONTROL_Properties);
|
||||
spa_pod_builder_add_object(&b.b,
|
||||
SPA_TYPE_OBJECT_Props, 0,
|
||||
SPA_PROP_volume, SPA_POD_Float(vas));
|
||||
|
||||
volume_accum -= volume_step;
|
||||
volume_offs += ramp_step_samples;
|
||||
} while (volume_accum > end);
|
||||
if (offs >= samples)
|
||||
break;
|
||||
|
||||
offs = SPA_MIN(samples, offs + step);
|
||||
}
|
||||
|
||||
return spa_pod_builder_pop(&b.b, &f[0]);
|
||||
}
|
||||
|
||||
static void generate_volume_ramp(struct impl *this, struct volume_ramp_params *vrp,
|
||||
void *buffer, size_t size)
|
||||
{
|
||||
void *sequence = NULL;
|
||||
if (vrp->start == vrp->end)
|
||||
spa_log_error(this->log, "no change in volume, cannot ramp volume");
|
||||
else if (vrp->end > vrp->start)
|
||||
sequence = generate_ramp_up_seq(this, vrp, buffer, size);
|
||||
else
|
||||
sequence = generate_ramp_down_seq(this, vrp, buffer, size);
|
||||
void *sequence;
|
||||
|
||||
sequence = generate_ramp_seq(this, vrp, buffer, size);
|
||||
if (!sequence)
|
||||
spa_log_error(this->log, "unable to generate sequence");
|
||||
|
||||
|
|
|
|||
|
|
@ -125,7 +125,7 @@ sparesampledumpcoeffs_sources = [
|
|||
sparesampledumpcoeffs = executable(
|
||||
'spa-resample-dump-coeffs',
|
||||
sparesampledumpcoeffs_sources,
|
||||
c_args : [ cc_flags_native, '-DRESAMPLE_DISABLE_PRECOMP' ],
|
||||
c_args : [ '-DRESAMPLE_DISABLE_PRECOMP' ],
|
||||
dependencies : [ spa_dep, mathlib_native ],
|
||||
install : false,
|
||||
native : true,
|
||||
|
|
|
|||
|
|
@ -252,7 +252,8 @@ static int update_string(struct pw_properties *props, const char *str, size_t si
|
|||
continue;
|
||||
}
|
||||
/* item changed or added, apply changes later */
|
||||
if ((errno = -add_item(&changes, key, false, val, true) < 0)) {
|
||||
if ((res = add_item(&changes, key, false, val, true)) < 0) {
|
||||
errno = -res;
|
||||
it[0].state = SPA_JSON_ERROR_FLAG;
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue