From: Arun Raghavan <git@xxxxxxxxxxxxxxxx> Needed for upcoming beamforming code. --- src/modules/echo-cancel/echo-cancel.h | 2 +- src/modules/echo-cancel/webrtc.cc | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/modules/echo-cancel/echo-cancel.h b/src/modules/echo-cancel/echo-cancel.h index 4c15717..ab0c5e9 100644 --- a/src/modules/echo-cancel/echo-cancel.h +++ b/src/modules/echo-cancel/echo-cancel.h @@ -65,7 +65,7 @@ struct pa_echo_canceller_params { * to C++ linkage. apm is a pointer to an AudioProcessing object */ void *apm; unsigned int blocksize; /* in frames */ - pa_sample_spec rec_ss, play_ss; + pa_sample_spec rec_ss, play_ss, out_ss; void *trace_callback; bool agc; bool first; diff --git a/src/modules/echo-cancel/webrtc.cc b/src/modules/echo-cancel/webrtc.cc index d918656..9b5ba94 100644 --- a/src/modules/echo-cancel/webrtc.cc +++ b/src/modules/echo-cancel/webrtc.cc @@ -335,6 +335,7 @@ bool pa_webrtc_ec_init(pa_core *c, pa_echo_canceller *ec, ec->params.webrtc.apm = apm; ec->params.webrtc.rec_ss = *rec_ss; ec->params.webrtc.play_ss = *play_ss; + ec->params.webrtc.out_ss = *out_ss; ec->params.webrtc.blocksize = (uint64_t) out_ss->rate * BLOCK_SIZE_US / PA_USEC_PER_SEC; *nframes = ec->params.webrtc.blocksize; ec->params.webrtc.first = true; @@ -374,17 +375,18 @@ void pa_webrtc_ec_play(pa_echo_canceller *ec, const uint8_t *play) { void pa_webrtc_ec_record(pa_echo_canceller *ec, const uint8_t *rec, uint8_t *out) { webrtc::AudioProcessing *apm = (webrtc::AudioProcessing*)ec->params.webrtc.apm; webrtc::AudioFrame out_frame; - const pa_sample_spec *ss = &ec->params.webrtc.rec_ss; + const pa_sample_spec *rec_ss = &ec->params.webrtc.rec_ss; + const pa_sample_spec *out_ss = &ec->params.webrtc.out_ss; pa_cvolume v; int old_volume, new_volume; - out_frame.num_channels_ = ss->channels; - out_frame.sample_rate_hz_ = ss->rate; + out_frame.num_channels_ = rec_ss->channels; + out_frame.sample_rate_hz_ = rec_ss->rate; out_frame.interleaved_ = true; out_frame.samples_per_channel_ = ec->params.webrtc.blocksize; pa_assert(out_frame.samples_per_channel_ <= webrtc::AudioFrame::kMaxDataSizeSamples); - memcpy(out_frame.data_, rec, ec->params.webrtc.blocksize * pa_frame_size(ss)); + memcpy(out_frame.data_, rec, ec->params.webrtc.blocksize * pa_frame_size(rec_ss)); if (ec->params.webrtc.agc) { pa_cvolume_init(&v); @@ -409,12 +411,12 @@ void pa_webrtc_ec_record(pa_echo_canceller *ec, const uint8_t *rec, uint8_t *out } if (old_volume != new_volume) { - pa_cvolume_set(&v, ss->channels, webrtc_volume_to_pa(new_volume)); + pa_cvolume_set(&v, rec_ss->channels, webrtc_volume_to_pa(new_volume)); pa_echo_canceller_set_capture_volume(ec, &v); } } - memcpy(out, out_frame.data_, ec->params.webrtc.blocksize * pa_frame_size(ss)); + memcpy(out, out_frame.data_, ec->params.webrtc.blocksize * pa_frame_size(out_ss)); } void pa_webrtc_ec_set_drift(pa_echo_canceller *ec, float drift) { -- 2.5.0