From e8769082e067df7ff206f25e0fabf10d56f2a023 Mon Sep 17 00:00:00 2001 From: Jaechul Lee Date: Mon, 6 Sep 2021 13:53:51 +0900 Subject: [PATCH] source-output: Prepare echo-cancellation functionality * Add echo-cancellation flags to source-output structure. * Add resampler2, memblock, processor to source-output structure. * Add post_process function to source_output domain [Version] 15.0-5 [Issue Type] New feature Change-Id: I310d9ddf26ddc340d447df571ac497c5a61cf116 Signed-off-by: Jaechul Lee --- meson.build | 4 ++++ meson_options.txt | 4 ++++ packaging/pulseaudio.spec | 4 ++-- src/pulsecore/source-output.c | 29 ++++++++++++++++++++++++++--- src/pulsecore/source-output.h | 16 +++++++++++++++- 5 files changed, 51 insertions(+), 6 deletions(-) diff --git a/meson.build b/meson.build index 519dcfc..3a41501 100644 --- a/meson.build +++ b/meson.build @@ -646,6 +646,10 @@ if lwipc_dep.found() cdata.set('TIZEN_TV_PROD_LWIPC', 1) endif +if get_option('aec') + cdata.set('TIZEN_AEC', 1) +endif + enable_security = false cynara_client_dep = dependency('cynara-client', required : get_option('security')) cynara_creds_socket_dep = dependency('cynara-creds-socket', required : get_option('security')) diff --git a/meson_options.txt b/meson_options.txt index 45ca254..76638e1 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -43,6 +43,10 @@ option('hal-datadir', option('hal-sysconfdir', type : 'string', description : 'Directory for HAL sysconf files') +option('aec', + type : 'boolean', value : true, + description : 'aec') + option('daemon', type : 'boolean', value : true, description : 'Enable building and installation of pulseaudio daemon and supporting configuration files') diff --git a/packaging/pulseaudio.spec b/packaging/pulseaudio.spec index 272bea7..0fce194 100644 --- a/packaging/pulseaudio.spec +++ b/packaging/pulseaudio.spec @@ -4,7 +4,7 @@ Name: pulseaudio Summary: Improved Linux sound server Version: 15.0 -Release: 4 +Release: 5 Group: Multimedia/Audio License: LGPL-2.1 URL: http://pulseaudio.org @@ -198,7 +198,7 @@ mkdir -p %{_vpath_builddir} -Dgsettings=disabled \ -Dhal-compat=false \ -Dipv6=false \ - %if "%{tizen_profile_name}" == "tv" +%if "%{tizen_profile_name}" == "tv" -Dprelink=true \ -Dlwipc=true \ -Dbluez5=false \ diff --git a/src/pulsecore/source-output.c b/src/pulsecore/source-output.c index 7ff352a..b587d29 100644 --- a/src/pulsecore/source-output.c +++ b/src/pulsecore/source-output.c @@ -849,6 +849,9 @@ void pa_source_output_push(pa_source_output *o, const pa_memchunk *chunk) { bool volume_is_norm; size_t length; size_t limit, mbs = 0; +#ifdef TIZEN_AEC + pa_memchunk ochunk = { .memblock = NULL }; +#endif pa_source_output_assert_ref(o); pa_source_output_assert_io_context(o); @@ -931,9 +934,16 @@ void pa_source_output_push(pa_source_output *o, const pa_memchunk *chunk) { pa_volume_memchunk(&qchunk, &o->source->sample_spec, &o->volume_factor_source); } - if (!o->thread_info.resampler) + if (!o->thread_info.resampler) { +#ifdef TIZEN_AEC + if (o->post_process && !o->post_process(o, &qchunk, &ochunk)) + o->push(o, &ochunk); + else + o->push(o, &qchunk); +#else o->push(o, &qchunk); - else { +#endif + } else { pa_memchunk rchunk; if (mbs == 0) @@ -944,8 +954,16 @@ void pa_source_output_push(pa_source_output *o, const pa_memchunk *chunk) { pa_resampler_run(o->thread_info.resampler, &qchunk, &rchunk); - if (rchunk.length > 0) + if (rchunk.length > 0) { +#ifdef TIZEN_AEC + if (o->post_process && !o->post_process(o, &rchunk, &ochunk)) + o->push(o, &ochunk); + else + o->push(o, &rchunk); +#else o->push(o, &rchunk); +#endif + } if (rchunk.memblock) pa_memblock_unref(rchunk.memblock); @@ -954,6 +972,11 @@ void pa_source_output_push(pa_source_output *o, const pa_memchunk *chunk) { pa_memblock_unref(qchunk.memblock); pa_memblockq_drop(o->thread_info.delay_memblockq, qchunk.length); } +#ifdef TIZEN_AEC + if (ochunk.memblock) + pa_memblock_unref(ochunk.memblock); +#endif + #ifdef TIZEN_PCM_DUMP pa_source_output_write_pcm_dump(o, (pa_memchunk *)chunk); #endif diff --git a/src/pulsecore/source-output.h b/src/pulsecore/source-output.h index 02f707b..570473a 100644 --- a/src/pulsecore/source-output.h +++ b/src/pulsecore/source-output.h @@ -56,7 +56,11 @@ typedef enum pa_source_output_flags { PA_SOURCE_OUTPUT_DONT_INHIBIT_AUTO_SUSPEND = 256, PA_SOURCE_OUTPUT_NO_CREATE_ON_SUSPEND = 512, PA_SOURCE_OUTPUT_KILL_ON_SUSPEND = 1024, - PA_SOURCE_OUTPUT_PASSTHROUGH = 2048 + PA_SOURCE_OUTPUT_PASSTHROUGH = 2048, +#ifdef __TIZEN__ + PA_SOURCE_OUTPUT_NOISE_SUPPRESSION = 4096, + PA_SOURCE_OUTPUT_ECHO_CANCEL = 8192 +#endif } pa_source_output_flags_t; struct pa_source_output { @@ -204,6 +208,10 @@ struct pa_source_output { * mute status changes. Called from main context */ void (*mute_changed)(pa_source_output *o); /* may be NULL */ +#ifdef __TIZEN__ + int (*post_process)(pa_source_output *o, pa_memchunk *chunk, pa_memchunk *ochunk); +#endif + struct { pa_source_output_state_t state; @@ -224,6 +232,12 @@ struct pa_source_output { pa_usec_t requested_source_latency; pa_sink_input *direct_on_input; /* may be NULL */ + +#ifdef __TIZEN__ + pa_memblockq *echo; + pa_resampler *resampler2; + void *processor; +#endif } thread_info; #ifdef __TIZEN__ pa_usec_t time_of_start_to_run; -- 2.7.4