Skip to content

Commit 8e8ff75

Browse files
johnylin76kv2019i
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>
1 parent 956b370 commit 8e8ff75

File tree

3 files changed

+30
-28
lines changed

3 files changed

+30
-28
lines changed

src/audio/multiband_drc/multiband_drc.c

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,16 @@ static int multiband_drc_init_coef(struct multiband_drc_comp_data *cd, int16_t n
135135
"multiband_drc_init_coef(), initializing %i-way crossover",
136136
config->num_bands);
137137

138+
/* Crossover: determine the split function */
139+
cd->crossover_split = crossover_find_split_func(config->num_bands);
140+
if (!cd->crossover_split) {
141+
comp_cl_err(&comp_multiband_drc,
142+
"multiband_drc_init_coef(), No crossover_split for band num %i",
143+
config->num_bands);
144+
ret = -EINVAL;
145+
goto err;
146+
}
147+
138148
/* Crossover: collect the coef array and assign it to every channel */
139149
crossover = config->crossover_coef;
140150
for (ch = 0; ch < nch; ch++) {
@@ -456,7 +466,10 @@ static void multiband_drc_process(struct comp_dev *dev, struct comp_buffer *sour
456466

457467
buffer_stream_invalidate(source, source_bytes);
458468

459-
cd->multiband_drc_func(dev, &source->stream, &sink->stream, frames);
469+
if (cd->process_enabled)
470+
cd->multiband_drc_func(dev, &source->stream, &sink->stream, frames);
471+
else
472+
multiband_drc_default_pass(dev, &source->stream, &sink->stream, frames);
460473

461474
buffer_stream_writeback(sink, sink_bytes);
462475

@@ -530,35 +543,19 @@ static int multiband_drc_prepare(struct comp_dev *dev)
530543
comp_dbg(dev, "multiband_drc_prepare(), source_format=%d, sink_format=%d",
531544
cd->source_format, cd->source_format);
532545
cd->config = comp_get_data_blob(cd->model_handler, NULL, NULL);
533-
if (cd->config && cd->process_enabled) {
546+
if (cd->config) {
534547
ret = multiband_drc_setup(cd, sourceb->stream.channels, sourceb->stream.rate);
535548
if (ret < 0) {
536549
comp_err(dev, "multiband_drc_prepare() error: multiband_drc_setup failed.");
537550
goto err;
538551
}
552+
}
539553

540-
cd->multiband_drc_func = multiband_drc_find_proc_func(cd->source_format);
541-
if (!cd->multiband_drc_func) {
542-
comp_err(dev, "multiband_drc_prepare(), No proc func");
543-
ret = -EINVAL;
544-
goto err;
545-
}
546-
547-
cd->crossover_split = crossover_find_split_func(cd->config->num_bands);
548-
if (!cd->crossover_split) {
549-
comp_err(dev, "multiband_drc_prepare(), No crossover_split for band num %i",
550-
cd->config->num_bands);
551-
ret = -EINVAL;
552-
goto err;
553-
}
554-
} else {
555-
comp_info(dev, "multiband_drc_prepare(), DRC is in passthrough mode");
556-
cd->multiband_drc_func = multiband_drc_find_proc_func_pass(cd->source_format);
557-
if (!cd->multiband_drc_func) {
558-
comp_err(dev, "multiband_drc_prepare(), No proc func passthrough");
559-
ret = -EINVAL;
560-
goto err;
561-
}
554+
cd->multiband_drc_func = multiband_drc_find_proc_func(cd->source_format);
555+
if (!cd->multiband_drc_func) {
556+
comp_err(dev, "multiband_drc_prepare(), No proc func");
557+
ret = -EINVAL;
558+
goto err;
562559
}
563560

564561
/* validate sink data format and period bytes */

src/audio/multiband_drc/multiband_drc_generic.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010
#include <sof/audio/multiband_drc/multiband_drc.h>
1111
#include <sof/math/iir_df2t.h>
1212

13-
static void multiband_drc_default_pass(const struct comp_dev *dev,
14-
const struct audio_stream *source,
15-
struct audio_stream *sink,
16-
uint32_t frames)
13+
void multiband_drc_default_pass(const struct comp_dev *dev,
14+
const struct audio_stream *source,
15+
struct audio_stream *sink,
16+
uint32_t frames)
1717
{
1818
audio_stream_copy(source, 0, sink, 0, source->channels * frames);
1919
}

src/include/sof/audio/multiband_drc/multiband_drc.h

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

55+
void multiband_drc_default_pass(const struct comp_dev *dev,
56+
const struct audio_stream *source,
57+
struct audio_stream *sink,
58+
uint32_t frames);
59+
5560
/**
5661
* \brief Returns Multiband DRC processing function.
5762
*/

0 commit comments

Comments
 (0)