Skip to content

Commit

Permalink
module_adapter: optimize buffer updates for consume and produce
Browse files Browse the repository at this point in the history
Direct call for buffer updates and avoid notify usage.

Signed-off-by: Liam Girdwood <[email protected]>
Signed-off-by: Baofeng Tian <[email protected]>
  • Loading branch information
lrgirdwo authored and kv2019i committed Jun 20, 2023
1 parent bd45a7e commit 89660c6
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/audio/module_adapter/module_adapter.c
Original file line number Diff line number Diff line change
Expand Up @@ -750,7 +750,7 @@ module_single_source_setup(struct comp_dev *dev,
struct list_item *blist;
uint32_t min_frames = UINT32_MAX;
uint32_t num_output_buffers;
uint32_t source_frame_bytes = 0;
uint32_t source_frame_bytes;
int i = 0;

source_frame_bytes = audio_stream_frame_bytes(&source_c[0]->stream);
Expand Down Expand Up @@ -840,8 +840,8 @@ static int module_adapter_audio_stream_type_copy(struct comp_dev *dev)
src_c = attr_container_of(mod->input_buffers[i].data,
struct comp_buffer __sparse_cache,
stream, __sparse_cache);

comp_update_buffer_consume(src_c, mod->input_buffers[i].consumed);
if (mod->input_buffers[i].consumed)
audio_stream_consume(&src_c->stream, mod->input_buffers[i].consumed);
}

/* compute data consumed based on pin 0 since it is processed with base config
Expand All @@ -868,7 +868,8 @@ static int module_adapter_audio_stream_type_copy(struct comp_dev *dev)

if (!mod->skip_sink_buffer_writeback)
buffer_stream_writeback(sink_c, mod->output_buffers[i].size);
comp_update_buffer_produce(sink_c, mod->output_buffers[i].size);
if (mod->output_buffers[i].size)
audio_stream_produce(&sink_c->stream, mod->output_buffers[i].size);
}

mod->total_data_produced += mod->output_buffers[0].size;
Expand Down

0 comments on commit 89660c6

Please sign in to comment.