On Thu, 2016-02-25 at 18:01 +0530, arun at accosted.net wrote: > From: Arun Raghavan <git at arunraghavan.net> > > It is expected that the underlying AGC mechanism will likely provide a > single volume for the source rather than a per-channel volume. Dealing > with per-channel volumes just adds complexity with regards to the > actual volume setting (depending on whether volume sharing is enabled or > not, we would set the volume on the source output of the virtual source, > and their sample specs may be different). > > Using a single volume maps allows us to sidestep this problem entirely. "maps" in the last line looks like it shouldn't be there. > Â /* Called by the canceller, so source I/O thread context. */ > -void pa_echo_canceller_set_capture_volume(pa_echo_canceller *ec, pa_cvolume *v) { > +void pa_echo_canceller_set_capture_volume(pa_echo_canceller *ec, pa_volume_t v) { > Â #ifndef ECHO_CANCEL_TEST > -Â Â Â Â if (!pa_cvolume_equal(&ec->msg->userdata->thread_info.current_volume, v)) { > -Â Â Â Â Â Â Â Â pa_cvolume *vol = pa_xnewdup(pa_cvolume, v, 1); > - > -Â Â Â Â Â Â Â Â pa_asyncmsgq_post(pa_thread_mq_get()->outq, PA_MSGOBJECT(ec->msg), ECHO_CANCELLER_MESSAGE_SET_VOLUME, vol, 0, NULL, > -Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â pa_xfree); > +Â Â Â Â if (pa_cvolume_avg(&ec->msg->userdata->thread_info.current_volume) != v) { > +Â Â Â Â Â Â Â Â pa_asyncmsgq_post(pa_thread_mq_get()->outq, PA_MSGOBJECT(ec->msg), ECHO_CANCELLER_MESSAGE_SET_VOLUME, PA_UINT_TO_PTR(v), > +Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 0, NULL, NULL); Since pa_volume_t is defined to be 32 bits, maybe it would be better to use PA_UINT32_TO_PTR here (and PA_PTR_TO_UINT32 when converting back). I guess in practice this doesn't matter, though. > Â Â Â Â Â } > Â #endif > Â } > diff --git a/src/modules/echo-cancel/webrtc.cc b/src/modules/echo-cancel/webrtc.cc > index 12bb556..f8aee33 100644 > --- a/src/modules/echo-cancel/webrtc.cc > +++ b/src/modules/echo-cancel/webrtc.cc > @@ -537,9 +537,8 @@ void pa_webrtc_ec_record(pa_echo_canceller *ec, const uint8_t *rec, uint8_t *out > Â Â Â Â Â pa_deinterleave(rec, (void **) buf, rec_ss->channels, pa_sample_size(rec_ss), n); > Â > Â Â Â Â Â if (ec->params.webrtc.agc) { > -Â Â Â Â Â Â Â Â pa_cvolume_init(&v); > -Â Â Â Â Â Â Â Â pa_echo_canceller_get_capture_volume(ec, &v); > -Â Â Â Â Â Â Â Â old_volume = webrtc_volume_from_pa(pa_cvolume_avg(&v)); > +Â Â Â Â Â Â Â Â pa_volume_t v = pa_echo_canceller_get_capture_volume(ec); v is declared already earlier (the earlier declaration should be removed). -- Tanu