Skip to content

Commit

Permalink
buf: make all the modules use comp_dev_get_first_data_consumer
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
marcinszkudlinski committed Sep 16, 2024
1 parent 0a7e3a7 commit 86cacaa
Show file tree
Hide file tree
Showing 37 changed files with 56 additions and 86 deletions.
2 changes: 1 addition & 1 deletion src/audio/aria/aria.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 ||
Expand Down
11 changes: 4 additions & 7 deletions src/audio/asrc/asrc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/audio/copier/copier_ipcgtw.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 1 addition & 3 deletions src/audio/dai-legacy.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
7 changes: 2 additions & 5 deletions src/audio/dai-zephyr.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion src/audio/dcblock/dcblock.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/audio/dcblock/dcblock_ipc4.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions src/audio/drc/drc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/audio/eq_fir/eq_fir.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/audio/eq_fir/eq_fir_ipc4.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/audio/eq_iir/eq_iir.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
3 changes: 1 addition & 2 deletions src/audio/eq_iir/eq_iir_ipc3.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion src/audio/eq_iir/eq_iir_ipc4.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
4 changes: 1 addition & 3 deletions src/audio/host-legacy.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 1 addition & 3 deletions src/audio/host-zephyr.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/audio/mfcc/mfcc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 1 addition & 2 deletions src/audio/mixer/mixer.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
3 changes: 1 addition & 2 deletions src/audio/module_adapter/module/waves/waves.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/audio/multiband_drc/multiband_drc_ipc4.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 1 addition & 2 deletions src/audio/mux/mux_generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/audio/mux/mux_ipc4.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions src/audio/rtnr/rtnr.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down
18 changes: 7 additions & 11 deletions src/audio/selector/selector.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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");
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -715,15 +711,15 @@ 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);
}
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;
Expand Down Expand Up @@ -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);
Expand Down
3 changes: 1 addition & 2 deletions src/audio/smart_amp/smart_amp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/audio/tdfb/tdfb.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/audio/tdfb/tdfb_ipc4.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
3 changes: 1 addition & 2 deletions src/audio/tone.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 1 addition & 2 deletions src/audio/volume/volume.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
3 changes: 1 addition & 2 deletions src/audio/volume/volume_ipc3.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Loading

0 comments on commit 86cacaa

Please sign in to comment.