From 86cacaad2c203695f08dd069dd6656dfdcadd5bf Mon Sep 17 00:00:00 2001 From: Marcin Szkudlinski Date: Mon, 16 Sep 2024 13:56:53 +0200 Subject: [PATCH] buf: make all the modules use comp_dev_get_first_data_consumer Change all access to the first element of dev->bsink_list from direct to API call comp_dev_get_first_data_consumer access in pipeline management code, like module adapter, is omitted intentionally Signed-off-by: Marcin Szkudlinski --- src/audio/aria/aria.c | 2 +- src/audio/asrc/asrc.c | 11 ++++------- src/audio/copier/copier_ipcgtw.c | 2 +- src/audio/dai-legacy.c | 4 +--- src/audio/dai-zephyr.c | 7 ++----- src/audio/dcblock/dcblock.c | 2 +- src/audio/dcblock/dcblock_ipc4.c | 2 +- src/audio/drc/drc.c | 4 ++-- src/audio/eq_fir/eq_fir.c | 2 +- src/audio/eq_fir/eq_fir_ipc4.c | 2 +- src/audio/eq_iir/eq_iir.c | 2 +- src/audio/eq_iir/eq_iir_ipc3.c | 3 +-- src/audio/eq_iir/eq_iir_ipc4.c | 2 +- src/audio/host-legacy.c | 4 +--- src/audio/host-zephyr.c | 4 +--- src/audio/mfcc/mfcc.c | 2 +- src/audio/mixer/mixer.c | 3 +-- src/audio/module_adapter/module/waves/waves.c | 3 +-- src/audio/multiband_drc/multiband_drc_ipc4.c | 2 +- src/audio/mux/mux_generic.c | 3 +-- src/audio/mux/mux_ipc4.c | 2 +- src/audio/rtnr/rtnr.c | 4 ++-- src/audio/selector/selector.c | 18 +++++++----------- src/audio/smart_amp/smart_amp.c | 3 +-- src/audio/tdfb/tdfb.c | 2 +- src/audio/tdfb/tdfb_ipc4.c | 2 +- src/audio/tone.c | 3 +-- src/audio/volume/volume.c | 3 +-- src/audio/volume/volume_ipc3.c | 3 +-- src/audio/volume/volume_ipc4.c | 2 +- src/ipc/ipc-helper.c | 7 ++----- src/samples/audio/smart_amp_test_ipc3.c | 3 +-- test/cmocka/src/audio/eq_fir/eq_fir_process.c | 6 +++--- test/cmocka/src/audio/eq_iir/eq_iir_process.c | 6 +++--- tools/plugin/modules/alsa.c | 4 ++-- tools/plugin/modules/shm.c | 3 +-- tools/testbench/file.c | 5 ++--- 37 files changed, 56 insertions(+), 86 deletions(-) diff --git a/src/audio/aria/aria.c b/src/audio/aria/aria.c index 7f3d3e5e10f8..c375ea8bb61f 100644 --- a/src/audio/aria/aria.c +++ b/src/audio/aria/aria.c @@ -181,7 +181,7 @@ static int aria_prepare(struct processing_module *mod, source = list_first_item(&dev->bsource_list, struct comp_buffer, sink_list); aria_set_stream_params(source, mod); - sink = list_first_item(&dev->bsink_list, struct comp_buffer, source_list); + sink = comp_dev_get_first_data_consumer(dev); aria_set_stream_params(sink, mod); if (audio_stream_get_valid_fmt(&source->stream) != SOF_IPC_FRAME_S24_4LE || diff --git a/src/audio/asrc/asrc.c b/src/audio/asrc/asrc.c index b67ac3e8518d..9adcd18e8baa 100644 --- a/src/audio/asrc/asrc.c +++ b/src/audio/asrc/asrc.c @@ -398,8 +398,7 @@ static int asrc_params(struct processing_module *mod) sourceb = list_first_item(&dev->bsource_list, struct comp_buffer, sink_list); - sinkb = list_first_item(&dev->bsink_list, struct comp_buffer, - source_list); + sinkb = comp_dev_get_first_data_consumer(dev); /* update the source/sink buffer formats. Sink rate will be modified below */ asrc_update_buffer_format(sourceb, cd); @@ -452,7 +451,7 @@ static int asrc_dai_find(struct comp_dev *dev, struct comp_data *cd) if (cd->mode == ASRC_OM_PUSH) { /* In push mode check if sink component is DAI */ do { - sinkb = list_first_item(&dev->bsink_list, struct comp_buffer, source_list); + sinkb = comp_dev_get_first_data_consumer(dev); dev = sinkb->sink; @@ -547,8 +546,7 @@ static int asrc_prepare(struct processing_module *mod, /* SRC component will only ever have 1 source and 1 sink buffer */ sourceb = list_first_item(&dev->bsource_list, struct comp_buffer, sink_list); - sinkb = list_first_item(&dev->bsink_list, - struct comp_buffer, source_list); + sinkb = comp_dev_get_first_data_consumer(dev); /* get source data format and period bytes */ cd->source_format = audio_stream_get_frm_fmt(&sourceb->stream); @@ -798,8 +796,7 @@ static int asrc_process(struct processing_module *mod, /* asrc component needs 1 source and 1 sink buffer */ source = list_first_item(&dev->bsource_list, struct comp_buffer, sink_list); - sink = list_first_item(&dev->bsink_list, struct comp_buffer, - source_list); + sink = comp_dev_get_first_data_consumer(dev); frames_src = audio_stream_get_avail_frames(source_s); frames_snk = audio_stream_get_free_frames(sink_s); diff --git a/src/audio/copier/copier_ipcgtw.c b/src/audio/copier/copier_ipcgtw.c index b5dccbd12986..81d39d3bdfa6 100644 --- a/src/audio/copier/copier_ipcgtw.c +++ b/src/audio/copier/copier_ipcgtw.c @@ -75,7 +75,7 @@ static inline struct comp_buffer *get_buffer(struct comp_dev *dev) if (dev->direction == SOF_IPC_STREAM_PLAYBACK) { if (list_is_empty(&dev->bsink_list)) return NULL; - return list_first_item(&dev->bsink_list, struct comp_buffer, source_list); + return comp_dev_get_first_data_consumer(dev); } assert(dev->direction == SOF_IPC_STREAM_CAPTURE); diff --git a/src/audio/dai-legacy.c b/src/audio/dai-legacy.c index af28b8616d9c..10c1aeb586a2 100644 --- a/src/audio/dai-legacy.c +++ b/src/audio/dai-legacy.c @@ -497,9 +497,7 @@ int dai_common_params(struct dai_data *dd, struct comp_dev *dev, struct comp_buffer, sink_list); else - dd->local_buffer = list_first_item(&dev->bsink_list, - struct comp_buffer, - source_list); + dd->local_buffer = comp_dev_get_first_data_consumer(dev); /* check if already configured */ if (dev->state == COMP_STATE_PREPARE) { diff --git a/src/audio/dai-zephyr.c b/src/audio/dai-zephyr.c index aea7a64d1031..d2e672e700c1 100644 --- a/src/audio/dai-zephyr.c +++ b/src/audio/dai-zephyr.c @@ -855,8 +855,7 @@ static int dai_set_dma_buffer(struct dai_data *dd, struct comp_dev *dev, dd->local_buffer = list_first_item(&dev->bsource_list, struct comp_buffer, sink_list); else - dd->local_buffer = list_first_item(&dev->bsink_list, struct comp_buffer, - source_list); + dd->local_buffer = comp_dev_get_first_data_consumer(dev); /* check if already configured */ if (dev->state == COMP_STATE_PREPARE) { @@ -1528,9 +1527,7 @@ static void set_new_local_buffer(struct dai_data *dd, struct comp_dev *dev) struct comp_buffer, sink_list); else - dd->local_buffer = list_first_item(&dev->bsink_list, - struct comp_buffer, - source_list); + dd->local_buffer = comp_dev_get_first_data_consumer(dev); local_fmt = audio_stream_get_frm_fmt(&dd->local_buffer->stream); diff --git a/src/audio/dcblock/dcblock.c b/src/audio/dcblock/dcblock.c index 6b7c23edd906..20b051eb0f63 100644 --- a/src/audio/dcblock/dcblock.c +++ b/src/audio/dcblock/dcblock.c @@ -200,7 +200,7 @@ static int dcblock_prepare(struct processing_module *mod, /* DC Filter component will only ever have one source and sink buffer */ sourceb = list_first_item(&dev->bsource_list, struct comp_buffer, sink_list); - sinkb = list_first_item(&dev->bsink_list, struct comp_buffer, source_list); + sinkb = comp_dev_get_first_data_consumer(dev); /* get source data format */ cd->source_format = audio_stream_get_frm_fmt(&sourceb->stream); diff --git a/src/audio/dcblock/dcblock_ipc4.c b/src/audio/dcblock/dcblock_ipc4.c index e89dc0a22415..c9da0d6f902c 100644 --- a/src/audio/dcblock/dcblock_ipc4.c +++ b/src/audio/dcblock/dcblock_ipc4.c @@ -61,7 +61,7 @@ void dcblock_params(struct processing_module *mod) ipc4_base_module_cfg_to_stream_params(&mod->priv.cfg.base_cfg, params); component_set_nearest_period_frames(dev, params->rate); - sinkb = list_first_item(&dev->bsink_list, struct comp_buffer, source_list); + sinkb = comp_dev_get_first_data_consumer(dev); ipc4_update_buffer_format(sinkb, &mod->priv.cfg.base_cfg.audio_fmt); sourceb = list_first_item(&dev->bsource_list, struct comp_buffer, sink_list); diff --git a/src/audio/drc/drc.c b/src/audio/drc/drc.c index 13b33415953b..eda040d6b869 100644 --- a/src/audio/drc/drc.c +++ b/src/audio/drc/drc.c @@ -303,7 +303,7 @@ static void drc_params(struct processing_module *mod) ipc4_base_module_cfg_to_stream_params(&mod->priv.cfg.base_cfg, params); component_set_nearest_period_frames(dev, params->rate); - sinkb = list_first_item(&dev->bsink_list, struct comp_buffer, source_list); + sinkb = comp_dev_get_first_data_consumer(dev); ipc4_update_buffer_format(sinkb, &mod->priv.cfg.base_cfg.audio_fmt); sourceb = list_first_item(&dev->bsource_list, struct comp_buffer, sink_list); @@ -330,7 +330,7 @@ static int drc_prepare(struct processing_module *mod, /* DRC component will only ever have 1 source and 1 sink buffer */ sourceb = list_first_item(&dev->bsource_list, struct comp_buffer, sink_list); - sinkb = list_first_item(&dev->bsink_list, struct comp_buffer, source_list); + sinkb = comp_dev_get_first_data_consumer(dev); /* get source data format */ cd->source_format = audio_stream_get_frm_fmt(&sourceb->stream); diff --git a/src/audio/eq_fir/eq_fir.c b/src/audio/eq_fir/eq_fir.c index 13871815ffdb..8587686b3021 100644 --- a/src/audio/eq_fir/eq_fir.c +++ b/src/audio/eq_fir/eq_fir.c @@ -425,7 +425,7 @@ static int eq_fir_prepare(struct processing_module *mod, /* EQ component will only ever have 1 source and 1 sink buffer. */ sourceb = list_first_item(&dev->bsource_list, struct comp_buffer, sink_list); - sinkb = list_first_item(&dev->bsink_list, struct comp_buffer, source_list); + sinkb = comp_dev_get_first_data_consumer(dev); eq_fir_set_alignment(&sourceb->stream, &sinkb->stream); channels = audio_stream_get_channels(&sinkb->stream); frame_fmt = audio_stream_get_frm_fmt(&sourceb->stream); diff --git a/src/audio/eq_fir/eq_fir_ipc4.c b/src/audio/eq_fir/eq_fir_ipc4.c index 047d74e0e3b9..c23c00f56d52 100644 --- a/src/audio/eq_fir/eq_fir_ipc4.c +++ b/src/audio/eq_fir/eq_fir_ipc4.c @@ -62,7 +62,7 @@ int eq_fir_params(struct processing_module *mod) sourceb = list_first_item(&dev->bsource_list, struct comp_buffer, sink_list); ipc4_update_buffer_format(sourceb, &mod->priv.cfg.base_cfg.audio_fmt); - sinkb = list_first_item(&dev->bsink_list, struct comp_buffer, source_list); + sinkb = comp_dev_get_first_data_consumer(dev); ipc4_update_buffer_format(sinkb, &mod->priv.cfg.base_cfg.audio_fmt); return 0; diff --git a/src/audio/eq_iir/eq_iir.c b/src/audio/eq_iir/eq_iir.c index a5b04a418691..10d0cbeb3c16 100644 --- a/src/audio/eq_iir/eq_iir.c +++ b/src/audio/eq_iir/eq_iir.c @@ -194,7 +194,7 @@ static int eq_iir_prepare(struct processing_module *mod, /* EQ component will only ever have 1 source and 1 sink buffer */ sourceb = list_first_item(&dev->bsource_list, struct comp_buffer, sink_list); - sinkb = list_first_item(&dev->bsink_list, struct comp_buffer, source_list); + sinkb = comp_dev_get_first_data_consumer(dev); eq_iir_set_alignment(&sourceb->stream, &sinkb->stream); /* get source and sink data format */ diff --git a/src/audio/eq_iir/eq_iir_ipc3.c b/src/audio/eq_iir/eq_iir_ipc3.c index 6958dd6b536b..2ce335a0cd27 100644 --- a/src/audio/eq_iir/eq_iir_ipc3.c +++ b/src/audio/eq_iir/eq_iir_ipc3.c @@ -276,8 +276,7 @@ static int eq_iir_verify_params(struct comp_dev *dev, /* EQ component will only ever have 1 source and 1 sink buffer */ sourceb = list_first_item(&dev->bsource_list, struct comp_buffer, sink_list); - sinkb = list_first_item(&dev->bsink_list, struct comp_buffer, - source_list); + sinkb = comp_dev_get_first_data_consumer(dev); /* we check whether we can support frame_fmt conversion (whether we have * such conversion function) due to source and sink buffer frame_fmt's. diff --git a/src/audio/eq_iir/eq_iir_ipc4.c b/src/audio/eq_iir/eq_iir_ipc4.c index 474b820b14de..7106ec3d7343 100644 --- a/src/audio/eq_iir/eq_iir_ipc4.c +++ b/src/audio/eq_iir/eq_iir_ipc4.c @@ -125,7 +125,7 @@ static int eq_iir_params(struct processing_module *mod) comp_params.chmap[i] = (mod->priv.cfg.base_cfg.audio_fmt.ch_map >> i * 4) & 0xf; component_set_nearest_period_frames(dev, comp_params.rate); - sinkb = list_first_item(&dev->bsink_list, struct comp_buffer, source_list); + sinkb = comp_dev_get_first_data_consumer(dev); ret = buffer_set_params(sinkb, &comp_params, true); return ret; } diff --git a/src/audio/host-legacy.c b/src/audio/host-legacy.c index 5326845fe021..94a39296f264 100644 --- a/src/audio/host-legacy.c +++ b/src/audio/host-legacy.c @@ -712,9 +712,7 @@ int host_common_params(struct host_data *hd, struct comp_dev *dev, } if (dev->direction == SOF_IPC_STREAM_PLAYBACK) - hd->local_buffer = list_first_item(&dev->bsink_list, - struct comp_buffer, - source_list); + hd->local_buffer = comp_dev_get_first_data_consumer(dev); else hd->local_buffer = list_first_item(&dev->bsource_list, struct comp_buffer, diff --git a/src/audio/host-zephyr.c b/src/audio/host-zephyr.c index ac1751059eb5..cecf9d1547b5 100644 --- a/src/audio/host-zephyr.c +++ b/src/audio/host-zephyr.c @@ -793,9 +793,7 @@ int host_common_params(struct host_data *hd, struct comp_dev *dev, } if (params->direction == SOF_IPC_STREAM_PLAYBACK) - hd->local_buffer = list_first_item(&dev->bsink_list, - struct comp_buffer, - source_list); + hd->local_buffer = comp_dev_get_first_data_consumer(dev); else hd->local_buffer = list_first_item(&dev->bsource_list, struct comp_buffer, diff --git a/src/audio/mfcc/mfcc.c b/src/audio/mfcc/mfcc.c index bc07a5058496..a2f88850991d 100644 --- a/src/audio/mfcc/mfcc.c +++ b/src/audio/mfcc/mfcc.c @@ -193,7 +193,7 @@ static int mfcc_prepare(struct processing_module *mod, /* MFCC component will only ever have 1 source and 1 sink buffer */ sourceb = list_first_item(&dev->bsource_list, struct comp_buffer, sink_list); - sinkb = list_first_item(&dev->bsink_list, struct comp_buffer, source_list); + sinkb = comp_dev_get_first_data_consumer(dev); /* get source data format */ source_format = audio_stream_get_frm_fmt(&sourceb->stream); diff --git a/src/audio/mixer/mixer.c b/src/audio/mixer/mixer.c index 6e9d6acf4493..e037852b079e 100644 --- a/src/audio/mixer/mixer.c +++ b/src/audio/mixer/mixer.c @@ -216,8 +216,7 @@ static int mixer_prepare(struct processing_module *mod, struct comp_buffer *sink; struct list_item *blist; - sink = list_first_item(&dev->bsink_list, struct comp_buffer, - source_list); + sink = comp_dev_get_first_data_consumer(dev); md->mix_func = mixer_get_processing_function(dev, sink); mixer_set_frame_alignment(&sink->stream); diff --git a/src/audio/module_adapter/module/waves/waves.c b/src/audio/module_adapter/module/waves/waves.c index efa1780fd482..7569873a2ac0 100644 --- a/src/audio/module_adapter/module/waves/waves.c +++ b/src/audio/module_adapter/module/waves/waves.c @@ -215,8 +215,7 @@ static int waves_effect_allocate(struct processing_module *mod) /* checks if sink/source parameters fit MaxxEffect */ static int waves_effect_check(struct comp_dev *dev) { - struct comp_buffer *sink = list_first_item(&dev->bsink_list, struct comp_buffer, - source_list); + struct comp_buffer *sink = comp_dev_get_first_data_consumer(dev); struct comp_buffer *source = list_first_item(&dev->bsource_list, struct comp_buffer, sink_list); const struct audio_stream *src_fmt = &source->stream; diff --git a/src/audio/multiband_drc/multiband_drc_ipc4.c b/src/audio/multiband_drc/multiband_drc_ipc4.c index e2471d6f2a8e..a573d1101c5b 100644 --- a/src/audio/multiband_drc/multiband_drc_ipc4.c +++ b/src/audio/multiband_drc/multiband_drc_ipc4.c @@ -98,7 +98,7 @@ int multiband_drc_params(struct processing_module *mod) comp_params.chmap[i] = (mod->priv.cfg.base_cfg.audio_fmt.ch_map >> i * 4) & 0xf; component_set_nearest_period_frames(dev, comp_params.rate); - sinkb = list_first_item(&dev->bsink_list, struct comp_buffer, source_list); + sinkb = comp_dev_get_first_data_consumer(dev); ret = buffer_set_params(sinkb, &comp_params, true); return ret; diff --git a/src/audio/mux/mux_generic.c b/src/audio/mux/mux_generic.c index ee4b1eddc91c..2bf3afe010cf 100644 --- a/src/audio/mux/mux_generic.c +++ b/src/audio/mux/mux_generic.c @@ -527,8 +527,7 @@ mux_func mux_get_processing_function(struct processing_module *mod) if (list_is_empty(&dev->bsink_list)) return NULL; - sinkb = list_first_item(&dev->bsink_list, struct comp_buffer, - source_list); + sinkb = comp_dev_get_first_data_consumer(dev); for (i = 0; i < ARRAY_SIZE(mux_func_map); i++) { enum sof_ipc_frame fmt = audio_stream_get_frm_fmt(&sinkb->stream); diff --git a/src/audio/mux/mux_ipc4.c b/src/audio/mux/mux_ipc4.c index 72c9e9e29c7d..bd0071901805 100644 --- a/src/audio/mux/mux_ipc4.c +++ b/src/audio/mux/mux_ipc4.c @@ -94,7 +94,7 @@ static void set_mux_params(struct processing_module *mod) /* update sink format */ if (!list_is_empty(&dev->bsink_list)) { - sink = list_first_item(&dev->bsink_list, struct comp_buffer, source_list); + sink = comp_dev_get_first_data_consumer(dev); if (!sink->hw_params_configured) { ipc4_update_buffer_format(sink, &cd->md.output_format); diff --git a/src/audio/rtnr/rtnr.c b/src/audio/rtnr/rtnr.c index c12034b6e793..5e4bd2cb7e39 100644 --- a/src/audio/rtnr/rtnr.c +++ b/src/audio/rtnr/rtnr.c @@ -784,7 +784,7 @@ static void rtnr_params(struct processing_module *mod) sourceb = list_first_item(&dev->bsource_list, struct comp_buffer, sink_list); ipc4_update_buffer_format(sourceb, &mod->priv.cfg.base_cfg.audio_fmt); - sinkb = list_first_item(&dev->bsink_list, struct comp_buffer, source_list); + sinkb = comp_dev_get_first_data_consumer(dev); ipc4_update_buffer_format(sinkb, &mod->priv.cfg.base_cfg.audio_fmt); } #endif @@ -814,7 +814,7 @@ static int rtnr_prepare(struct processing_module *mod, /* Initialize RTNR */ /* Get sink data format */ - sinkb = list_first_item(&dev->bsink_list, struct comp_buffer, source_list); + sinkb = comp_dev_get_first_data_consumer(dev); cd->sink_format = audio_stream_get_frm_fmt(&sinkb->stream); cd->sink_stream.frame_fmt = audio_stream_get_frm_fmt(&sinkb->stream); sourceb = list_first_item(&dev->bsource_list, struct comp_buffer, sink_list); diff --git a/src/audio/selector/selector.c b/src/audio/selector/selector.c index 79140baec302..506853043420 100644 --- a/src/audio/selector/selector.c +++ b/src/audio/selector/selector.c @@ -62,8 +62,7 @@ static int selector_verify_params(struct comp_dev *dev, comp_dbg(dev, "selector_verify_params()"); - sinkb = list_first_item(&dev->bsink_list, struct comp_buffer, - source_list); + sinkb = comp_dev_get_first_data_consumer(dev); /* check whether params->channels (received from driver) are equal to * cd->config.in_channels_count (PLAYBACK) or @@ -73,8 +72,7 @@ static int selector_verify_params(struct comp_dev *dev, */ if (dev->direction == SOF_IPC_STREAM_PLAYBACK) { /* fetch sink buffer for playback */ - buffer = list_first_item(&dev->bsink_list, struct comp_buffer, - source_list); + buffer = comp_dev_get_first_data_consumer(dev); if (cd->config.in_channels_count && cd->config.in_channels_count != params->channels) { comp_err(dev, "selector_verify_params(): src in_channels_count does not match pcm channels"); @@ -387,8 +385,7 @@ static int selector_copy(struct comp_dev *dev) /* selector component will have 1 source and 1 sink buffer */ source = list_first_item(&dev->bsource_list, struct comp_buffer, sink_list); - sink = list_first_item(&dev->bsink_list, struct comp_buffer, - source_list); + sink = comp_dev_get_first_data_consumer(dev); if (!audio_stream_get_avail(&source->stream)) return PPL_STATUS_PATH_STOP; @@ -436,8 +433,7 @@ static int selector_prepare(struct comp_dev *dev) /* selector component will have 1 source and 1 sink buffer */ sourceb = list_first_item(&dev->bsource_list, struct comp_buffer, sink_list); - sinkb = list_first_item(&dev->bsink_list, struct comp_buffer, - source_list); + sinkb = comp_dev_get_first_data_consumer(dev); /* get source data format and period bytes */ cd->source_format = audio_stream_get_frm_fmt(&sourceb->stream); @@ -715,7 +711,7 @@ static int selector_verify_params(struct processing_module *mod, /* apply input/output channels count according to stream direction */ if (dev->direction == SOF_IPC_STREAM_PLAYBACK) { params->channels = out_channels; - buffer = list_first_item(&dev->bsink_list, struct comp_buffer, source_list); + buffer = comp_dev_get_first_data_consumer(dev); } else { params->channels = in_channels; buffer = list_first_item(&dev->bsource_list, struct comp_buffer, sink_list); @@ -723,7 +719,7 @@ static int selector_verify_params(struct processing_module *mod, buffer_set_params(buffer, params, BUFFER_UPDATE_FORCE); /* set component period frames */ - buffer = list_first_item(&dev->bsink_list, struct comp_buffer, source_list); + buffer = comp_dev_get_first_data_consumer(dev); component_set_nearest_period_frames(dev, audio_stream_get_rate(&buffer->stream)); return 0; @@ -844,7 +840,7 @@ static int selector_prepare(struct processing_module *mod, /* selector component will have 1 source and 1 sink buffer */ sourceb = list_first_item(&dev->bsource_list, struct comp_buffer, sink_list); - sinkb = list_first_item(&dev->bsink_list, struct comp_buffer, source_list); + sinkb = comp_dev_get_first_data_consumer(dev); audio_stream_set_align(4, 1, &sourceb->stream); audio_stream_set_align(4, 1, &sinkb->stream); diff --git a/src/audio/smart_amp/smart_amp.c b/src/audio/smart_amp/smart_amp.c index 154761fd0937..80100022ef71 100644 --- a/src/audio/smart_amp/smart_amp.c +++ b/src/audio/smart_amp/smart_amp.c @@ -755,8 +755,7 @@ static int smart_amp_prepare(struct comp_dev *dev) } /* sink buffer */ - sad->sink_buf = list_first_item(&dev->bsink_list, struct comp_buffer, - source_list); + sad->sink_buf = comp_dev_get_first_data_consumer(dev); /* get frame format and channels param of stream and feedback source */ ff_src_fmt = audio_stream_get_frm_fmt(&sad->source_buf->stream); diff --git a/src/audio/tdfb/tdfb.c b/src/audio/tdfb/tdfb.c index 128a39b19e1c..7b5202adeecb 100644 --- a/src/audio/tdfb/tdfb.c +++ b/src/audio/tdfb/tdfb.c @@ -740,7 +740,7 @@ static int tdfb_prepare(struct processing_module *mod, /* Find source and sink buffers */ sourceb = list_first_item(&dev->bsource_list, struct comp_buffer, sink_list); - sinkb = list_first_item(&dev->bsink_list, struct comp_buffer, source_list); + sinkb = comp_dev_get_first_data_consumer(dev); tdfb_set_alignment(&sourceb->stream, &sinkb->stream); frame_fmt = audio_stream_get_frm_fmt(&sourceb->stream); diff --git a/src/audio/tdfb/tdfb_ipc4.c b/src/audio/tdfb/tdfb_ipc4.c index 5360b1013e97..ad262fedd7e0 100644 --- a/src/audio/tdfb/tdfb_ipc4.c +++ b/src/audio/tdfb/tdfb_ipc4.c @@ -201,7 +201,7 @@ int tdfb_params(struct processing_module *mod) sourceb = list_first_item(&dev->bsource_list, struct comp_buffer, sink_list); ipc4_update_buffer_format(sourceb, &mod->priv.cfg.input_pins[0].audio_fmt); - sinkb = list_first_item(&dev->bsink_list, struct comp_buffer, source_list); + sinkb = comp_dev_get_first_data_consumer(dev); ipc4_update_buffer_format(sinkb, &mod->priv.cfg.output_pins[0].audio_fmt); return 0; } diff --git a/src/audio/tone.c b/src/audio/tone.c index d1975029fa04..5906f3ac9e71 100644 --- a/src/audio/tone.c +++ b/src/audio/tone.c @@ -431,8 +431,7 @@ static int tone_params(struct comp_dev *dev, sourceb = list_first_item(&dev->bsource_list, struct comp_buffer, sink_list); - sinkb = list_first_item(&dev->bsink_list, struct comp_buffer, - source_list); + sinkb = comp_dev_get_first_data_consumer(dev); comp_info(dev, "tone_params(), config->frame_fmt = %u", dev->ipc_config.frame_fmt); diff --git a/src/audio/volume/volume.c b/src/audio/volume/volume.c index de7ae63d1116..e94bd8822671 100644 --- a/src/audio/volume/volume.c +++ b/src/audio/volume/volume.c @@ -684,8 +684,7 @@ static int volume_prepare(struct processing_module *mod, ret = volume_peak_prepare(cd, mod); /* volume component will only ever have 1 sink and source buffer */ - sinkb = list_first_item(&dev->bsink_list, - struct comp_buffer, source_list); + sinkb = comp_dev_get_first_data_consumer(dev); sourceb = list_first_item(&dev->bsource_list, struct comp_buffer, sink_list); diff --git a/src/audio/volume/volume_ipc3.c b/src/audio/volume/volume_ipc3.c index 2c65f6bba2dc..f02ee74109a1 100644 --- a/src/audio/volume/volume_ipc3.c +++ b/src/audio/volume/volume_ipc3.c @@ -42,8 +42,7 @@ void set_volume_process(struct vol_data *cd, struct comp_dev *dev, bool source_o bufferb = list_first_item(&dev->bsource_list, struct comp_buffer, sink_list); else - bufferb = list_first_item(&dev->bsink_list, - struct comp_buffer, source_list); + bufferb = comp_dev_get_first_data_consumer(dev); cd->scale_vol = vol_get_processing_function(dev, bufferb, cd); } diff --git a/src/audio/volume/volume_ipc4.c b/src/audio/volume/volume_ipc4.c index 947d88a323b9..b495c6868666 100644 --- a/src/audio/volume/volume_ipc4.c +++ b/src/audio/volume/volume_ipc4.c @@ -413,7 +413,7 @@ static int volume_params(struct processing_module *mod) component_set_nearest_period_frames(dev, params->rate); /* volume component will only ever have 1 sink buffer */ - sinkb = list_first_item(&dev->bsink_list, struct comp_buffer, source_list); + sinkb = comp_dev_get_first_data_consumer(dev); ipc4_update_buffer_format(sinkb, &mod->priv.cfg.base_cfg.audio_fmt); sourceb = list_first_item(&dev->bsource_list, struct comp_buffer, sink_list); diff --git a/src/ipc/ipc-helper.c b/src/ipc/ipc-helper.c index 43926002abe3..b9f11811a8f0 100644 --- a/src/ipc/ipc-helper.c +++ b/src/ipc/ipc-helper.c @@ -140,9 +140,7 @@ int comp_verify_params(struct comp_dev *dev, uint32_t flag, struct comp_buffer, sink_list); else - buf = list_first_item(sink_list, - struct comp_buffer, - source_list); + buf = list_first_item(sink_list, struct comp_buffer, source_list); /* update specific pcm parameter with buffer parameter if * specific flag is set. @@ -169,8 +167,7 @@ int comp_verify_params(struct comp_dev *dev, uint32_t flag, } /* fetch sink buffer in order to calculate period frames */ - sinkb = list_first_item(&dev->bsink_list, struct comp_buffer, - source_list); + sinkb = comp_dev_get_first_data_consumer(dev); component_set_nearest_period_frames(dev, audio_stream_get_rate(&sinkb->stream)); } diff --git a/src/samples/audio/smart_amp_test_ipc3.c b/src/samples/audio/smart_amp_test_ipc3.c index 9de3bacb76d5..5406c41b1037 100644 --- a/src/samples/audio/smart_amp_test_ipc3.c +++ b/src/samples/audio/smart_amp_test_ipc3.c @@ -511,8 +511,7 @@ static int smart_amp_prepare(struct comp_dev *dev) sad->source_buf = source_buffer; } - sad->sink_buf = list_first_item(&dev->bsink_list, struct comp_buffer, - source_list); + sad->sink_buf = comp_dev_get_first_data_consumer(dev); sad->out_channels = audio_stream_get_channels(&sad->sink_buf->stream); diff --git a/test/cmocka/src/audio/eq_fir/eq_fir_process.c b/test/cmocka/src/audio/eq_fir/eq_fir_process.c index a847a4d34fb6..22f2a9103c64 100644 --- a/test/cmocka/src/audio/eq_fir/eq_fir_process.c +++ b/test/cmocka/src/audio/eq_fir/eq_fir_process.c @@ -246,7 +246,7 @@ static void verify_sink_s16(struct test_data *td) int samples; int i; - sb = list_first_item(&dev->bsink_list, struct comp_buffer, source_list); + sb = comp_dev_get_first_data_consumer(dev); ss = &sb->stream; samples = mod->output_buffers[0].size >> 1; for (i = 0; i < samples; i++) { @@ -312,7 +312,7 @@ static void verify_sink_s24(struct test_data *td) int samples; int i; - sb = list_first_item(&dev->bsink_list, struct comp_buffer, source_list); + sb = comp_dev_get_first_data_consumer(dev); ss = &sb->stream; samples = mod->output_buffers[0].size >> 2; for (i = 0; i < samples; i++) { @@ -378,7 +378,7 @@ static void verify_sink_s32(struct test_data *td) int samples; int i; - sb = list_first_item(&dev->bsink_list, struct comp_buffer, source_list); + sb = comp_dev_get_first_data_consumer(dev); ss = &sb->stream; samples = mod->output_buffers[0].size >> 2; for (i = 0; i < samples; i++) { diff --git a/test/cmocka/src/audio/eq_iir/eq_iir_process.c b/test/cmocka/src/audio/eq_iir/eq_iir_process.c index fa18cf5b0c3f..b22d14b396e9 100644 --- a/test/cmocka/src/audio/eq_iir/eq_iir_process.c +++ b/test/cmocka/src/audio/eq_iir/eq_iir_process.c @@ -245,7 +245,7 @@ static void verify_sink_s16(struct test_data *td) int samples; int i; - sb = list_first_item(&dev->bsink_list, struct comp_buffer, source_list); + sb = comp_dev_get_first_data_consumer(dev); ss = &sb->stream; samples = mod->output_buffers[0].size >> 1; for (i = 0; i < samples; i++) { @@ -308,7 +308,7 @@ static void verify_sink_s24(struct test_data *td) int samples; int i; - sb = list_first_item(&dev->bsink_list, struct comp_buffer, source_list); + sb = comp_dev_get_first_data_consumer(dev); ss = &sb->stream; samples = mod->output_buffers[0].size >> 2; for (i = 0; i < samples; i++) { @@ -371,7 +371,7 @@ static void verify_sink_s32(struct test_data *td) int samples; int i; - sb = list_first_item(&dev->bsink_list, struct comp_buffer, source_list); + sb = comp_dev_get_first_data_consumer(dev); ss = &sb->stream; samples = mod->output_buffers[0].size >> 2; for (i = 0; i < samples; i++) { diff --git a/tools/plugin/modules/alsa.c b/tools/plugin/modules/alsa.c index 8d45597d6227..a3543260b721 100644 --- a/tools/plugin/modules/alsa.c +++ b/tools/plugin/modules/alsa.c @@ -428,7 +428,7 @@ static int arecord_params(struct comp_dev *dev, struct sof_ipc_stream_params *pa memcpy(&cd->params, params, sizeof(*params)); /* file component sink/source buffer period count */ - buffer = list_first_item(&dev->bsink_list, struct comp_buffer, source_list); + buffer = comp_dev_get_first_data_consumer(dev); buffer_reset_pos(buffer, NULL); comp_dbg(dev, "prepare done ret = %d", ret); @@ -529,7 +529,7 @@ static int arecord_copy(struct comp_dev *dev) } /* file component sink buffer */ - buffer = list_first_item(&dev->bsink_list, struct comp_buffer, source_list); + buffer = comp_dev_get_first_data_consumer(dev); sink = &buffer->stream; pos = sink->w_ptr; diff --git a/tools/plugin/modules/shm.c b/tools/plugin/modules/shm.c index 0e990bfe7cd0..c9aaa5e3b7e6 100644 --- a/tools/plugin/modules/shm.c +++ b/tools/plugin/modules/shm.c @@ -306,8 +306,7 @@ static int shmwrite_copy(struct comp_dev *dev) void *src; /* local SOF sink buffer */ - buffer = list_first_item(&dev->bsink_list, struct comp_buffer, - source_list); + buffer = comp_dev_get_first_data_consumer(dev); sink = &buffer->stream; wptr = sink->w_ptr; diff --git a/tools/testbench/file.c b/tools/testbench/file.c index 1ce8b578d6c7..b70d04cf1934 100644 --- a/tools/testbench/file.c +++ b/tools/testbench/file.c @@ -702,7 +702,7 @@ static int file_params(struct comp_dev *dev, /* file component sink/source buffer period count */ switch (cd->fs.mode) { case FILE_READ: - buffer = list_first_item(&dev->bsink_list, struct comp_buffer, source_list); + buffer = comp_dev_get_first_data_consumer(dev); periods = dev->ipc_config.periods_sink; break; case FILE_WRITE: @@ -812,8 +812,7 @@ static int file_copy(struct comp_dev *dev) switch (cd->fs.mode) { case FILE_READ: /* file component sink buffer */ - buffer = list_first_item(&dev->bsink_list, struct comp_buffer, - source_list); + buffer = comp_dev_get_first_data_consumer(dev); /* test sink has enough free frames */ snk_frames = MIN(audio_stream_get_free_frames(&buffer->stream), dev->frames);