[pulseaudio-discuss] [PATCH v3 17/24] echo-cancel: Fix webrtc canceller when rec channels != play channels

Tanu Kaskinen tanuk at iki.fi
Mon Feb 8 09:02:59 CET 2016


On Mon, 2016-01-18 at 13:06 +0530, arun at accosted.net wrote:
> From: Arun Raghavan <git at arunraghavan.net>
> 
> The calculations around how many samples were sent to the canceller
> engine was not updated when we started supporting different channel
> counts for playback and capture.
> ---
>  src/modules/echo-cancel/echo-cancel.h |  4 ++--
>  src/modules/echo-cancel/webrtc.cc     | 25 +++++++++++++------------
>  2 files changed, 15 insertions(+), 14 deletions(-)
> 
> diff --git a/src/modules/echo-cancel/echo-cancel.h b/src/modules/echo-cancel/echo-cancel.h
> index 37f99c0..4693516 100644
> --- a/src/modules/echo-cancel/echo-cancel.h
> +++ b/src/modules/echo-cancel/echo-cancel.h
> @@ -64,8 +64,8 @@ struct pa_echo_canceller_params {
>              /* This is a void* so that we don't have to convert this whole file
>               * to C++ linkage. apm is a pointer to an AudioProcessing object */
>              void *apm;
> -            uint32_t blocksize;
> -            pa_sample_spec sample_spec;
> +            int32_t blocksize; /* in frames */

Why is the type changed from unsigned to signed? It doesn't look like
you need negative values.

> +            pa_sample_spec rec_ss, play_ss;
>              bool agc;
>              bool trace;
>              bool first;
> diff --git a/src/modules/echo-cancel/webrtc.cc b/src/modules/echo-cancel/webrtc.cc
> index ec0a383..2732b38 100644
> --- a/src/modules/echo-cancel/webrtc.cc
> +++ b/src/modules/echo-cancel/webrtc.cc
> @@ -327,9 +327,11 @@ bool pa_webrtc_ec_init(pa_core *c, pa_echo_canceller *ec,
>          apm->voice_detection()->Enable(true);
>  
>      ec->params.webrtc.apm = apm;
> -    ec->params.webrtc.sample_spec = *out_ss;
> -    ec->params.webrtc.blocksize = (uint64_t)pa_bytes_per_second(out_ss) * BLOCK_SIZE_US / PA_USEC_PER_SEC;
> -    *nframes = ec->params.webrtc.blocksize / pa_frame_size(out_ss);
> +    ec->params.webrtc.rec_ss = *rec_ss;
> +    ec->params.webrtc.play_ss = *play_ss;
> +    ec->params.webrtc.blocksize =
> +        (uint64_t) (pa_bytes_per_second(out_ss) / pa_frame_size(out_ss)) * BLOCK_SIZE_US / PA_USEC_PER_SEC;

pa_bytes_per_second(out_ss) / pa_frame_size(out_ss) calculates the
sample rate, so it can be replaced with out_ss->rate.

-- 
Tanu


More information about the pulseaudio-discuss mailing list