Skip to content

Commit 22154ed

Browse files
ranj063macchian
authored andcommitted
module_adapter: separate handling the processed output into a new function
Split the core for handling the processed output into a separate function. Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
1 parent af188b1 commit 22154ed

1 file changed

Lines changed: 46 additions & 36 deletions

File tree

src/audio/module_adapter/module_adapter.c

Lines changed: 46 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,51 @@ static void module_copy_samples(struct comp_dev *dev, struct comp_buffer *src_bu
463463
comp_update_buffer_consume(src_buffer, copy_bytes);
464464
}
465465

466+
static void module_adapter_process_output(struct comp_dev *dev)
467+
{
468+
struct processing_module *mod = comp_get_drvdata(dev);
469+
struct comp_buffer *sink;
470+
struct list_item *blist;
471+
int i;
472+
473+
/*
474+
* copy all produced output samples to output buffers. This loop will do nothing when
475+
* there are no samples produced.
476+
*/
477+
i = 0;
478+
list_for_item(blist, &mod->sink_buffer_list) {
479+
if (mod->output_buffers[i].size > 0) {
480+
struct comp_buffer *buffer;
481+
482+
buffer = container_of(blist, struct comp_buffer, sink_list);
483+
ca_copy_from_module_to_sink(&buffer->stream, mod->output_buffers[i].data,
484+
mod->output_buffers[i].size);
485+
audio_stream_produce(&buffer->stream, mod->output_buffers[i].size);
486+
}
487+
i++;
488+
}
489+
490+
/* copy from all output local buffers to sink buffers */
491+
i = 0;
492+
list_for_item(blist, &dev->bsink_list) {
493+
struct list_item *_blist;
494+
int j = 0;
495+
496+
sink = container_of(blist, struct comp_buffer, source_list);
497+
list_for_item(_blist, &mod->sink_buffer_list) {
498+
if (i == j) {
499+
struct comp_buffer *src_buffer;
500+
501+
src_buffer = container_of(_blist, struct comp_buffer, sink_list);
502+
module_copy_samples(dev, src_buffer, sink,
503+
mod->output_buffers[i].size);
504+
break;
505+
}
506+
j++;
507+
}
508+
}
509+
}
510+
466511
int module_adapter_copy(struct comp_dev *dev)
467512
{
468513
struct comp_buffer *source;
@@ -511,26 +556,9 @@ int module_adapter_copy(struct comp_dev *dev)
511556
goto out;
512557
}
513558

514-
/*
515-
* the loop to copy output samples will do nothing when ret is -ENODATA or
516-
* -ENOSPC because there will be no samples produced
517-
*/
518559
ret = 0;
519560
}
520561

521-
/* copy all produced output samples to output buffers */
522-
i = 0;
523-
list_for_item(blist, &mod->sink_buffer_list) {
524-
struct comp_buffer *buffer = container_of(blist, struct comp_buffer, sink_list);
525-
526-
if (mod->output_buffers[i].size > 0) {
527-
ca_copy_from_module_to_sink(&buffer->stream, mod->output_buffers[i].data,
528-
mod->output_buffers[i].size);
529-
audio_stream_produce(&buffer->stream, mod->output_buffers[i].size);
530-
}
531-
i++;
532-
}
533-
534562
/* consume from all input buffers */
535563
i = 0;
536564
list_for_item(blist, &dev->bsource_list) {
@@ -539,25 +567,7 @@ int module_adapter_copy(struct comp_dev *dev)
539567
i++;
540568
}
541569

542-
/* copy from all output local buffers to sink buffers */
543-
i = 0;
544-
list_for_item(blist, &dev->bsink_list) {
545-
struct comp_buffer *src_buffer;
546-
struct list_item *_blist;
547-
int j = 0;
548-
549-
sink = container_of(blist, struct comp_buffer, source_list);
550-
list_for_item(_blist, &mod->sink_buffer_list) {
551-
src_buffer = container_of(_blist, struct comp_buffer, sink_list);
552-
553-
if (i == j) {
554-
module_copy_samples(dev, src_buffer, sink,
555-
mod->output_buffers[i].size);
556-
break;
557-
}
558-
j++;
559-
}
560-
}
570+
module_adapter_process_output(dev);
561571
out:
562572
for (i = 0; i < mod->num_output_buffers; i++)
563573
mod->output_buffers[i].size = 0;

0 commit comments

Comments
 (0)