audioconvert: always use DSP rate on DSP ports

Always use the DSP rate on DSP ports for format conversion, not the
previous used rate.

This avoids some resampler reconfiguration as it negotiates a non-passthrough
rate conversion and then switches to passthrough when the rate correction is
done to match the graph rate.

See #2614
This commit is contained in:
Wim Taymans 2022-08-03 11:32:10 +02:00
parent e7f17e1523
commit a23d154952
2 changed files with 13 additions and 7 deletions

View file

@ -1471,26 +1471,29 @@ static int setup_convert(struct impl *this)
rate = this->io_position ? this->io_position->clock.rate.denom : DEFAULT_RATE;
if (in->format.info.raw.rate == 0 && in->mode == SPA_PARAM_PORT_CONFIG_MODE_dsp)
/* in DSP mode we always convert to the DSP rate */
if (in->mode == SPA_PARAM_PORT_CONFIG_MODE_dsp)
in->format.info.raw.rate = rate;
if (out->format.info.raw.rate == 0 && out->mode == SPA_PARAM_PORT_CONFIG_MODE_dsp)
if (out->mode == SPA_PARAM_PORT_CONFIG_MODE_dsp)
out->format.info.raw.rate = rate;
/* try to passthrough the rates */
if (in->format.info.raw.rate == 0)
in->format.info.raw.rate = out->format.info.raw.rate;
else if (out->format.info.raw.rate == 0)
out->format.info.raw.rate = in->format.info.raw.rate;
if (in->format.info.raw.rate == 0 && out->format.info.raw.rate == 0)
return -EINVAL;
if (in->format.info.raw.channels == 0 && out->format.info.raw.channels == 0)
return -EINVAL;
/* try to passthrough the channels */
if (in->format.info.raw.channels == 0)
in->format.info.raw.channels = out->format.info.raw.channels;
else if (out->format.info.raw.channels == 0)
out->format.info.raw.channels = in->format.info.raw.channels;
if (in->format.info.raw.rate == 0 || out->format.info.raw.rate == 0)
return -EINVAL;
if (in->format.info.raw.channels == 0 || out->format.info.raw.channels == 0)
return -EINVAL;
if ((res = setup_in_convert(this)) < 0)
return res;
if ((res = setup_channelmix(this)) < 0)