[PATCH 3/3] echo-cancel: Warn on different sample rates for rec, play, out stream

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, 2013-02-07 at 14:40 +0100, Stefan Huber wrote:
> The current echo-cancel framework does not support different sample
> rates for the rec, play and out stream as it is assumed that the blocks
> passed to the EC implementation's run() cover equal time spans. However,
> pa__init() does not check that. Fix this.
> ---
>  src/modules/echo-cancel/module-echo-cancel.c |   14 ++++++++++++++
>  1 file changed, 14 insertions(+)
> 
> diff --git a/src/modules/echo-cancel/module-echo-cancel.c b/src/modules/echo-cancel/module-echo-cancel.c
> index a140902..4ee36eb 100644
> --- a/src/modules/echo-cancel/module-echo-cancel.c
> +++ b/src/modules/echo-cancel/module-echo-cancel.c
> @@ -1743,12 +1743,26 @@ int pa__init(pa_module*m) {
>      source_output_ss = source_ss;
>      source_output_map = source_map;
>  
> +    if (sink_ss.rate != source_ss.rate) {
> +        pa_log_info("Sample rates of play and out stream differ. Adjusting rate of play stream.");
> +        sink_ss.rate = source_ss.rate;
> +    }
> +
>      pa_assert(u->ec->init);
>      if (!u->ec->init(u->core, u->ec, &source_output_ss, &source_output_map, &sink_ss, &sink_map, &source_ss, &source_map, &nframes, pa_modargs_get_value(ma, "aec_args", NULL))) {
>          pa_log("Failed to init AEC engine");
>          goto fail;
>      }
>  
> +    if (source_output_ss.rate != source_ss.rate) {
> +        pa_log_error("Sample rates of rec and out stream differ, which is not supported. Adjusting rate of rec stream.");
> +        source_output_ss.rate = source_ss.rate;
> +    }
> +    if (sink_ss.rate != source_ss.rate) {
> +        pa_log_error("Sample rates of play and out stream differ, which is not supported. Adjusting rate of play stream.");
> +        sink_ss.rate = source_ss.rate;
> +    }

Isn't it a bug in the canceller init() function if it modifies the rates
in an incompatible way? The cancellers probably rely on the parameters
being what init() set them to, so modifying the parameters after the
init() call doesn't seem like a good idea. I think assertions would be
appropriate here.

-- 
Tanu



[Index of Archives]     [Linux Audio Users]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux