Skip to content

Commit 6ca76d5

Browse files
johnylin76lgirdwood
authored andcommitted
multiband_drc: instantaneous enabled state switch on processing
In present multiband_drc design, the enabled state is determined by the switch control while multiband_drc starts to process. If the switch control toggles while processing, it will take effects on the next time multiband_drc starts to process. This commit makes change to let the enabled state update instantaneously by the switch control toggle when multiband_drc is processing. Signed-off-by: Pin-chih Lin <johnylin@google.com> (cherry picked from commit 8e8ff75)
1 parent 22c3285 commit 6ca76d5

3 files changed

Lines changed: 27 additions & 25 deletions

File tree

src/audio/multiband_drc/multiband_drc.c

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,14 @@ static int multiband_drc_init_coef(struct processing_module *mod, int16_t nch, u
126126
comp_info(dev, "multiband_drc_init_coef(), initializing %i-way crossover",
127127
config->num_bands);
128128

129+
/* Crossover: determine the split function */
130+
cd->crossover_split = crossover_find_split_func(config->num_bands);
131+
if (!cd->crossover_split) {
132+
comp_err(dev, "multiband_drc_init_coef(), No crossover_split for band count(%i)",
133+
config->num_bands);
134+
return -EINVAL;
135+
}
136+
129137
/* Crossover: collect the coef array and assign it to every channel */
130138
crossover = config->crossover_coef;
131139
for (ch = 0; ch < nch; ch++) {
@@ -328,7 +336,10 @@ static int multiband_drc_process(struct processing_module *mod,
328336
}
329337
}
330338

331-
cd->multiband_drc_func(mod, source, sink, frames);
339+
if (cd->process_enabled)
340+
cd->multiband_drc_func(mod, source, sink, frames);
341+
else
342+
multiband_drc_default_pass(mod, source, sink, frames);
332343

333344
/* calc new free and available */
334345
module_update_buffer_position(&input_buffers[0], &output_buffers[0], frames);
@@ -364,32 +375,18 @@ static int multiband_drc_prepare(struct processing_module *mod,
364375
comp_dbg(dev, "multiband_drc_prepare(), source_format=%d, sink_format=%d",
365376
cd->source_format, cd->source_format);
366377
cd->config = comp_get_data_blob(cd->model_handler, NULL, NULL);
367-
if (cd->config && cd->process_enabled) {
378+
if (cd->config) {
368379
ret = multiband_drc_setup(mod, channels, rate);
369380
if (ret < 0) {
370381
comp_err(dev, "multiband_drc_prepare() error: multiband_drc_setup failed.");
371382
return ret;
372383
}
384+
}
373385

374-
cd->multiband_drc_func = multiband_drc_find_proc_func(cd->source_format);
375-
if (!cd->multiband_drc_func) {
376-
comp_err(dev, "multiband_drc_prepare(), No proc func");
377-
return -EINVAL;
378-
}
379-
380-
cd->crossover_split = crossover_find_split_func(cd->config->num_bands);
381-
if (!cd->crossover_split) {
382-
comp_err(dev, "multiband_drc_prepare(), No crossover_split for band num %i",
383-
cd->config->num_bands);
384-
return -EINVAL;
385-
}
386-
} else {
387-
comp_info(dev, "multiband_drc_prepare(), DRC is in passthrough mode");
388-
cd->multiband_drc_func = multiband_drc_find_proc_func_pass(cd->source_format);
389-
if (!cd->multiband_drc_func) {
390-
comp_err(dev, "multiband_drc_prepare(), No proc func passthrough");
391-
return -EINVAL;
392-
}
386+
cd->multiband_drc_func = multiband_drc_find_proc_func(cd->source_format);
387+
if (!cd->multiband_drc_func) {
388+
comp_err(dev, "multiband_drc_prepare(), No proc func");
389+
return -EINVAL;
393390
}
394391

395392
return ret;

src/audio/multiband_drc/multiband_drc.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,11 @@ extern const struct multiband_drc_proc_fnmap multiband_drc_proc_fnmap[];
5454
extern const struct multiband_drc_proc_fnmap multiband_drc_proc_fnmap_pass[];
5555
extern const size_t multiband_drc_proc_fncount;
5656

57+
void multiband_drc_default_pass(const struct processing_module *mod,
58+
const struct audio_stream *source,
59+
struct audio_stream *sink,
60+
uint32_t frames);
61+
5762
/**
5863
* \brief Returns Multiband DRC processing function.
5964
*/

src/audio/multiband_drc/multiband_drc_generic.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
#include "multiband_drc.h"
1212
#include "../drc/drc_algorithm.h"
1313

14-
static void multiband_drc_default_pass(const struct processing_module *mod,
15-
const struct audio_stream *source,
16-
struct audio_stream *sink,
17-
uint32_t frames)
14+
void multiband_drc_default_pass(const struct processing_module *mod,
15+
const struct audio_stream *source,
16+
struct audio_stream *sink,
17+
uint32_t frames)
1818
{
1919
audio_stream_copy(source, 0, sink, 0, audio_stream_get_channels(source) * frames);
2020
}

0 commit comments

Comments
 (0)