[pulseaudio-discuss] [PATCH v3 09/24] echo-cancel: Allow enabling tracing output from the webrtc canceller
Arun Raghavan
arun at accosted.net
Mon Feb 1 21:19:44 PST 2016
On Sat, 2016-01-30 at 13:51 +0200, Tanu Kaskinen wrote:
> On Mon, 2016-01-18 at 13:06 +0530, arun at accosted.net wrote:
> > From: Arun Raghavan <git at arunraghavan.net>
> >
> > ---
> > src/modules/echo-cancel/echo-cancel.h | 1 +
> > src/modules/echo-cancel/webrtc.cc | 34
> > ++++++++++++++++++++++++++++++++++
> > 2 files changed, 35 insertions(+)
> >
> > diff --git a/src/modules/echo-cancel/echo-cancel.h
> > b/src/modules/echo-cancel/echo-cancel.h
> > index 29d1574..142f8ac 100644
> > --- a/src/modules/echo-cancel/echo-cancel.h
> > +++ b/src/modules/echo-cancel/echo-cancel.h
> > @@ -67,6 +67,7 @@ struct pa_echo_canceller_params {
> > uint32_t blocksize;
> > pa_sample_spec sample_spec;
> > bool agc;
> > + bool trace;
> > } webrtc;
> > #endif
> > /* each canceller-specific structure goes here */
> > diff --git a/src/modules/echo-cancel/webrtc.cc b/src/modules/echo-
> > cancel/webrtc.cc
> > index 4dbd2fc..53ab7e1 100644
> > --- a/src/modules/echo-cancel/webrtc.cc
> > +++ b/src/modules/echo-cancel/webrtc.cc
> > @@ -35,6 +35,7 @@ PA_C_DECL_END
> >
> > #include
> > #include
> > +#include
> >
> > #define BLOCK_SIZE_US 10000
> >
> > @@ -48,6 +49,7 @@ PA_C_DECL_END
> > #define DEFAULT_DRIFT_COMPENSATION false
> > #define DEFAULT_EXTENDED_FILTER false
> > #define DEFAULT_INTELLIGIBILITY_ENHANCER false
> > +#define DEFAULT_TRACE false
> >
> > static const char* const valid_modargs[] = {
> > "high_pass_filter",
> > @@ -60,6 +62,7 @@ static const char* const valid_modargs[] = {
> > "drift_compensation",
> > "extended_filter",
> > "intelligibility_enhancer",
> > + "trace",
> > NULL
> > };
> >
> > @@ -78,6 +81,20 @@ static int routing_mode_from_string(const char
> > *rmode) {
> > return -1;
> > }
> >
> > +class PaWebrtcTraceCallback : public webrtc::TraceCallback {
> > + void Print(webrtc::TraceLevel level, const char *message, int
> > length)
>
> I hope the presence of a length parameter doesn't mean that message
> isn't null-terminated.
I don't know why the length is there, but it is null-terminated.
> > + {
> > + if (level & webrtc::kTraceError || level &
> > webrtc::kTraceCritical)
> > + pa_log(message);
> > + else if (level & webrtc::kTraceWarning)
> > + pa_log_warn(message);
> > + else if (level & webrtc::kTraceInfo)
> > + pa_log_info(message);
> > + else
> > + pa_log_debug(message);
> > + }
> > +};
> > +
> > static void pa_webrtc_ec_fixate_spec(pa_sample_spec *rec_ss,
> > pa_channel_map *rec_map,
> > pa_sample_spec *play_ss,
> > pa_channel_map *play_map,
> > pa_sample_spec *out_ss,
> > pa_channel_map *out_map)
> > @@ -201,6 +218,18 @@ bool pa_webrtc_ec_init(pa_core *c,
> > pa_echo_canceller *ec,
> > if (intelligibility)
> > config.Set(new webrtc::Intelligibility(true));
> >
> > + ec->params.priv.webrtc.trace = DEFAULT_TRACE;
> > + if (pa_modargs_get_value_boolean(ma, "trace", &ec-
> > >params.priv.webrtc.trace) < 0) {
> > + pa_log("Failed to parse trace value");
> > + goto fail;
> > + }
> > +
> > + if (ec->params.priv.webrtc.trace) {
> > + webrtc::Trace::CreateTrace();
> > + webrtc::Trace::set_level_filter(webrtc::kTraceAll);
> > + webrtc::Trace::SetTraceCallback(new
> > PaWebrtcTraceCallback());
>
> Does webrtc::Trace delete the object that you allocate here?
It does not. I've now redone this and will send out the update.
> > + }
> > +
> > pa_webrtc_ec_fixate_spec(rec_ss, rec_map, play_ss, play_map,
> > out_ss, out_map);
> >
> > apm = webrtc::AudioProcessing::Create(config);
> > @@ -263,6 +292,8 @@ bool pa_webrtc_ec_init(pa_core *c,
> > pa_echo_canceller *ec,
> > fail:
> > if (ma)
> > pa_modargs_free(ma);
> > + if (ec->params.priv.webrtc.trace)
> > + webrtc::Trace::ReturnTrace();
>
> What does this do? Is it safe to call this if you haven't yet set up
> the tracing?
Drops the reference on the Trace objected created by CreateTrace().
Also fixed this up to be safe against initialisation.
-- Arun
More information about the pulseaudio-discuss
mailing list