Skip to content

Commit f2d4fa0

Browse files
ranj063macchian
authored andcommitted
module_adapter: optimize module_adapter_copy()
When the module produces only period_bytes every period, there's no need to save the produced samples in the intermediate local buffer, instead copy them directly to the sink buffer and save an extra copy. Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
1 parent b629896 commit f2d4fa0

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

src/audio/module_adapter/module_adapter.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,10 +466,28 @@ static void module_copy_samples(struct comp_dev *dev, struct comp_buffer *src_bu
466466
static void module_adapter_process_output(struct comp_dev *dev)
467467
{
468468
struct processing_module *mod = comp_get_drvdata(dev);
469+
struct module_data *md = &mod->priv;
469470
struct comp_buffer *sink;
470471
struct list_item *blist;
471472
int i;
472473

474+
/*
475+
* When a module produces only period_bytes every period, skip copying the produced
476+
* samples to the intermediate buffer and copy to the sink buffer directly
477+
*/
478+
if (md->mpd.out_buff_size == mod->period_bytes) {
479+
i = 0;
480+
list_for_item(blist, &dev->bsink_list) {
481+
sink = container_of(blist, struct comp_buffer, source_list);
482+
ca_copy_from_module_to_sink(&sink->stream, mod->output_buffers[i].data,
483+
mod->output_buffers[i].size);
484+
audio_stream_produce(&sink->stream, mod->output_buffers[i].size);
485+
mod->output_buffers[i].size = 0;
486+
i++;
487+
}
488+
return;
489+
}
490+
473491
/*
474492
* copy all produced output samples to output buffers. This loop will do nothing when
475493
* there are no samples produced.

0 commit comments

Comments
 (0)