Skip to content

Commit

Permalink
buf: make all the modules use comp_dev_get_first_data_producer
Browse files Browse the repository at this point in the history
Change all access to the first element of dev->bsource_list
from direct to API call comp_dev_get_first_data_producer

access in pipeline management code, like module adapter,
is omitted intentionally

Signed-off-by: Marcin Szkudlinski <[email protected]>
  • Loading branch information
marcinszkudlinski committed Sep 17, 2024
1 parent 6ca56c3 commit c610927
Show file tree
Hide file tree
Showing 40 changed files with 65 additions and 100 deletions.
2 changes: 1 addition & 1 deletion src/audio/aria/aria.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ static int aria_prepare(struct processing_module *mod,

comp_info(dev, "aria_prepare()");

source = list_first_item(&dev->bsource_list, struct comp_buffer, sink_list);
source = comp_dev_get_first_data_producer(dev);
aria_set_stream_params(source, mod);

sink = comp_dev_get_first_data_consumer(dev);
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 @@ -396,8 +396,7 @@ static int asrc_params(struct processing_module *mod)
return -EINVAL;
}

sourceb = list_first_item(&dev->bsource_list, struct comp_buffer,
sink_list);
sourceb = comp_dev_get_first_data_producer(dev);
sinkb = comp_dev_get_first_data_consumer(dev);

/* update the source/sink buffer formats. Sink rate will be modified below */
Expand Down Expand Up @@ -469,7 +468,7 @@ static int asrc_dai_find(struct comp_dev *dev, struct comp_data *cd)
} else {
/* In pull mode check if source component is DAI */
do {
sourceb = list_first_item(&dev->bsource_list, struct comp_buffer, sink_list);
sourceb = comp_dev_get_first_data_producer(dev);

dev = sourceb->source;

Expand Down Expand Up @@ -544,8 +543,7 @@ static int asrc_prepare(struct processing_module *mod,
return ret;

/* SRC component will only ever have 1 source and 1 sink buffer */
sourceb = list_first_item(&dev->bsource_list,
struct comp_buffer, sink_list);
sourceb = comp_dev_get_first_data_producer(dev);
sinkb = comp_dev_get_first_data_consumer(dev);

/* get source data format and period bytes */
Expand Down Expand Up @@ -794,8 +792,7 @@ static int asrc_process(struct processing_module *mod,
return ret;

/* asrc component needs 1 source and 1 sink buffer */
source = list_first_item(&dev->bsource_list, struct comp_buffer,
sink_list);
source = comp_dev_get_first_data_producer(dev);
sink = comp_dev_get_first_data_consumer(dev);

frames_src = audio_stream_get_avail_frames(source_s);
Expand Down
3 changes: 1 addition & 2 deletions src/audio/codec/dts/dts.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,7 @@ static int dts_effect_convert_sof_interface_result(struct comp_dev *dev,
static int dts_effect_populate_buffer_configuration(struct comp_dev *dev,
DtsSofInterfaceBufferConfiguration *buffer_config)
{
struct comp_buffer *source = list_first_item(&dev->bsource_list, struct comp_buffer,
sink_list);
struct comp_buffer *source = comp_dev_get_first_data_producer(dev);
const struct audio_stream *stream;
DtsSofInterfaceBufferLayout buffer_layout;
DtsSofInterfaceBufferFormat buffer_format;
Expand Down
6 changes: 3 additions & 3 deletions src/audio/copier/copier.c
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ static int copier_comp_trigger(struct comp_dev *dev, int cmd)
return -EINVAL;
}

buffer = list_first_item(&dai_copier->bsource_list, struct comp_buffer, sink_list);
buffer = comp_dev_get_first_data_producer(dai_copier);
pipe_reg.stream_start_offset = posn.dai_posn +
latency * audio_stream_period_bytes(&buffer->stream, dev->frames);
pipe_reg.stream_end_offset = 0;
Expand All @@ -412,7 +412,7 @@ static int copier_comp_trigger(struct comp_dev *dev, int cmd)
return -EINVAL;
}

buffer = list_first_item(&dai_copier->bsource_list, struct comp_buffer, sink_list);
buffer = comp_dev_get_first_data_producer(dai_copier);
pipe_reg.stream_start_offset += latency *
audio_stream_period_bytes(&buffer->stream, dev->frames);
mailbox_sw_regs_write(cd->pipeline_reg_offset, &pipe_reg.stream_start_offset,
Expand Down Expand Up @@ -561,7 +561,7 @@ static int copier_multi_endpoint_dai_copy(struct copier_data *cd, struct comp_de
return -EINVAL;
}

src = list_first_item(&dev->bsource_list, struct comp_buffer, sink_list);
src = comp_dev_get_first_data_producer(dev);

/* gateway(s) on output */
ret = do_conversion_copy(dev, cd, src, cd->multi_endpoint_buffer, &processed_data);
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 @@ -82,7 +82,7 @@ static inline struct comp_buffer *get_buffer(struct comp_dev *dev)

if (list_is_empty(&dev->bsource_list))
return NULL;
return list_first_item(&dev->bsource_list, struct comp_buffer, sink_list);
return comp_dev_get_first_data_producer(dev);
}

int copier_ipcgtw_process(const struct ipc4_ipcgtw_cmd *cmd,
Expand Down
2 changes: 1 addition & 1 deletion src/audio/crossover/crossover.c
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ static int crossover_prepare(struct processing_module *mod,

/* Crossover has a variable number of sinks */
mod->max_sinks = SOF_CROSSOVER_MAX_STREAMS;
source = list_first_item(&dev->bsource_list, struct comp_buffer, sink_list);
source = comp_dev_get_first_data_producer(dev);

/* Get source data format */
cd->source_format = audio_stream_get_frm_fmt(&source->stream);
Expand Down
2 changes: 1 addition & 1 deletion src/audio/crossover/crossover_ipc4.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ void crossover_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);

sourceb = list_first_item(&dev->bsource_list, struct comp_buffer, sink_list);
sourceb = comp_dev_get_first_data_producer(dev);
ipc4_update_buffer_format(sourceb, &mod->priv.cfg.base_cfg.audio_fmt);

comp_dev_for_each_consumer(dev, sinkb) {
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 @@ -493,9 +493,7 @@ int dai_common_params(struct dai_data *dd, struct comp_dev *dev,
}

if (dev->direction == SOF_IPC_STREAM_PLAYBACK)
dd->local_buffer = list_first_item(&dev->bsource_list,
struct comp_buffer,
sink_list);
dd->local_buffer = comp_dev_get_first_data_producer(dev);
else
dd->local_buffer = comp_dev_get_first_data_consumer(dev);

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 @@ -848,8 +848,7 @@ static int dai_set_dma_buffer(struct dai_data *dd, struct comp_dev *dev,
comp_dbg(dev, "dai_set_dma_buffer()");

if (dev->direction == SOF_IPC_STREAM_PLAYBACK)
dd->local_buffer = list_first_item(&dev->bsource_list, struct comp_buffer,
sink_list);
dd->local_buffer = comp_dev_get_first_data_producer(dev);
else
dd->local_buffer = comp_dev_get_first_data_consumer(dev);

Expand Down Expand Up @@ -1519,9 +1518,7 @@ static void set_new_local_buffer(struct dai_data *dd, struct comp_dev *dev)
uint32_t local_fmt;

if (dev->direction == SOF_IPC_STREAM_PLAYBACK)
dd->local_buffer = list_first_item(&dev->bsource_list,
struct comp_buffer,
sink_list);
dd->local_buffer = comp_dev_get_first_data_producer(dev);
else
dd->local_buffer = comp_dev_get_first_data_consumer(dev);

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 @@ -199,7 +199,7 @@ static int dcblock_prepare(struct processing_module *mod,
dcblock_params(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);
sourceb = comp_dev_get_first_data_producer(dev);
sinkb = comp_dev_get_first_data_consumer(dev);

/* get source data format */
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 @@ -64,7 +64,7 @@ void dcblock_params(struct processing_module *mod)
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);
sourceb = comp_dev_get_first_data_producer(dev);
ipc4_update_buffer_format(sourceb, &mod->priv.cfg.base_cfg.audio_fmt);
}

4 changes: 2 additions & 2 deletions src/audio/drc/drc.c
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ static void drc_params(struct processing_module *mod)
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);
sourceb = comp_dev_get_first_data_producer(dev);
ipc4_update_buffer_format(sourceb, &mod->priv.cfg.base_cfg.audio_fmt);
}
#endif /* CONFIG_IPC_MAJOR_4 */
Expand All @@ -329,7 +329,7 @@ static int drc_prepare(struct processing_module *mod,
#endif

/* DRC component will only ever have 1 source and 1 sink buffer */
sourceb = list_first_item(&dev->bsource_list, struct comp_buffer, sink_list);
sourceb = comp_dev_get_first_data_producer(dev);
sinkb = comp_dev_get_first_data_consumer(dev);

/* get source data format */
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 @@ -424,7 +424,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);
sourceb = comp_dev_get_first_data_producer(dev);
sinkb = comp_dev_get_first_data_consumer(dev);
eq_fir_set_alignment(&sourceb->stream, &sinkb->stream);
channels = audio_stream_get_channels(&sinkb->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 @@ -59,7 +59,7 @@ int eq_fir_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);

sourceb = list_first_item(&dev->bsource_list, struct comp_buffer, sink_list);
sourceb = comp_dev_get_first_data_producer(dev);
ipc4_update_buffer_format(sourceb, &mod->priv.cfg.base_cfg.audio_fmt);

sinkb = comp_dev_get_first_data_consumer(dev);
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 @@ -193,7 +193,7 @@ static int eq_iir_prepare(struct processing_module *mod,
return ret;

/* EQ component will only ever have 1 source and 1 sink buffer */
sourceb = list_first_item(&dev->bsource_list, struct comp_buffer, sink_list);
sourceb = comp_dev_get_first_data_producer(dev);
sinkb = comp_dev_get_first_data_consumer(dev);
eq_iir_set_alignment(&sourceb->stream, &sinkb->stream);

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 @@ -274,8 +274,7 @@ static int eq_iir_verify_params(struct comp_dev *dev,
comp_dbg(dev, "eq_iir_verify_params()");

/* EQ component will only ever have 1 source and 1 sink buffer */
sourceb = list_first_item(&dev->bsource_list, struct comp_buffer,
sink_list);
sourceb = comp_dev_get_first_data_producer(dev);
sinkb = comp_dev_get_first_data_consumer(dev);

/* we check whether we can support frame_fmt conversion (whether we have
Expand Down
2 changes: 1 addition & 1 deletion src/audio/google/google_ctc_audio_processing.c
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ static int ctc_prepare(struct processing_module *mod,

comp_info(mod->dev, "ctc_prepare()");

source = list_first_item(&dev->bsource_list, struct comp_buffer, sink_list);
source = comp_dev_get_first_data_producer(dev);
switch (audio_stream_get_frm_fmt(&source->stream)) {
#if CONFIG_FORMAT_S16LE
case SOF_IPC_FRAME_S16_LE:
Expand Down
6 changes: 2 additions & 4 deletions src/audio/google/google_hotword_detect.c
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,7 @@ static int ghd_params(struct comp_dev *dev,
}

/* This detector component will only ever have 1 source */
sourceb = list_first_item(&dev->bsource_list, struct comp_buffer,
sink_list);
sourceb = comp_dev_get_first_data_producer(dev);

if (audio_stream_get_channels(sourceb->stream) != 1) {
comp_err(dev, "ghd_params(): Only single-channel supported");
Expand Down Expand Up @@ -391,8 +390,7 @@ static int ghd_copy(struct comp_dev *dev)
}

/* keyword components will only ever have 1 source */
source = list_first_item(&dev->bsource_list,
struct comp_buffer, sink_list);
source = comp_dev_get_first_data_producer(dev);
stream = &sourceb->stream;

bytes = audio_stream_get_avail_bytes(stream);
Expand Down
5 changes: 2 additions & 3 deletions src/audio/google/google_rtc_audio_processing.c
Original file line number Diff line number Diff line change
Expand Up @@ -633,10 +633,9 @@ static int google_rtc_audio_processing_prepare(struct processing_module *mod,
/* Don't need the ref buffer on IPC4 as pipelines are always
* activated in tandem; also the API is deprecated
*/
cd->ref_comp_buffer = list_first_item(&dev->bsource_list,
struct comp_buffer, sink_list);
cd->ref_comp_buffer = comp_dev_get_first_data_producer(dev);
if (cd->aec_reference_source == 1)
cd->ref_comp_buffer = list_next_item(cd->ref_comp_buffer, sink_list);
cd->ref_comp_buffer = comp_dev_get_next_data_producer(dev, cd->ref_comp_buffer);
#endif

#ifdef CONFIG_IPC_MAJOR_4
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 @@ -714,9 +714,7 @@ int host_common_params(struct host_data *hd, struct comp_dev *dev,
if (dev->direction == SOF_IPC_STREAM_PLAYBACK)
hd->local_buffer = comp_dev_get_first_data_consumer(dev);
else
hd->local_buffer = list_first_item(&dev->bsource_list,
struct comp_buffer,
sink_list);
hd->local_buffer = comp_dev_get_first_data_producer(dev);

period_bytes = dev->frames *
audio_stream_frame_bytes(&hd->local_buffer->stream);
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 @@ -795,9 +795,7 @@ int host_common_params(struct host_data *hd, struct comp_dev *dev,
if (params->direction == SOF_IPC_STREAM_PLAYBACK)
hd->local_buffer = comp_dev_get_first_data_consumer(dev);
else
hd->local_buffer = list_first_item(&dev->bsource_list,
struct comp_buffer,
sink_list);
hd->local_buffer = comp_dev_get_first_data_producer(dev);

period_bytes = dev->frames * get_frame_bytes(params->frame_fmt, params->channels);

Expand Down
3 changes: 1 addition & 2 deletions src/audio/kpb.c
Original file line number Diff line number Diff line change
Expand Up @@ -1182,8 +1182,7 @@ static int kpb_copy(struct comp_dev *dev)
}

/* Get source and sink buffers */
source = list_first_item(&dev->bsource_list, struct comp_buffer,
sink_list);
source = comp_dev_get_first_data_producer(dev);

/* Validate source */
if (!audio_stream_get_rptr(&source->stream)) {
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 @@ -192,7 +192,7 @@ static int mfcc_prepare(struct processing_module *mod,
comp_info(dev, "mfcc_prepare()");

/* MFCC component will only ever have 1 source and 1 sink buffer */
sourceb = list_first_item(&dev->bsource_list, struct comp_buffer, sink_list);
sourceb = comp_dev_get_first_data_producer(dev);
sinkb = comp_dev_get_first_data_consumer(dev);

/* get source data format */
Expand Down
6 changes: 2 additions & 4 deletions src/audio/module_adapter/module/waves/waves.c
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,7 @@ static int waves_effect_allocate(struct processing_module *mod)
static int waves_effect_check(struct comp_dev *dev)
{
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);
struct comp_buffer *source = comp_dev_get_first_data_producer(dev);
const struct audio_stream *src_fmt = &source->stream;
const struct audio_stream *snk_fmt = &sink->stream;

Expand Down Expand Up @@ -283,8 +282,7 @@ static int waves_effect_check(struct comp_dev *dev)
static int waves_effect_init(struct processing_module *mod)
{
struct comp_dev *dev = mod->dev;
struct comp_buffer *source = list_first_item(&dev->bsource_list, struct comp_buffer,
sink_list);
struct comp_buffer *source = comp_dev_get_first_data_producer(dev);
struct module_data *codec = &mod->priv;
struct waves_codec_data *waves_codec = codec->private;
const struct audio_stream *src_fmt = &source->stream;
Expand Down
2 changes: 1 addition & 1 deletion src/audio/multiband_drc/multiband_drc.c
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ static int multiband_drc_prepare(struct processing_module *mod,
return ret;

/* DRC component will only ever have 1 source and 1 sink buffer */
sourceb = list_first_item(&dev->bsource_list, struct comp_buffer, sink_list);
sourceb = comp_dev_get_first_data_producer(dev);

/* get source data format */
cd->source_format = audio_stream_get_frm_fmt(&sourceb->stream);
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 @@ -549,8 +549,7 @@ demux_func demux_get_processing_function(struct processing_module *mod)
if (list_is_empty(&dev->bsource_list))
return NULL;

sourceb = list_first_item(&dev->bsource_list, struct comp_buffer,
sink_list);
sourceb = comp_dev_get_first_data_producer(dev);

for (i = 0; i < ARRAY_SIZE(mux_func_map); i++) {
enum sof_ipc_frame fmt = audio_stream_get_frm_fmt(&sourceb->stream);
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 @@ -781,7 +781,7 @@ static void rtnr_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);

sourceb = list_first_item(&dev->bsource_list, struct comp_buffer, sink_list);
sourceb = comp_dev_get_first_data_producer(dev);
ipc4_update_buffer_format(sourceb, &mod->priv.cfg.base_cfg.audio_fmt);

sinkb = comp_dev_get_first_data_consumer(dev);
Expand Down Expand Up @@ -817,7 +817,7 @@ static int rtnr_prepare(struct processing_module *mod,
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);
sourceb = comp_dev_get_first_data_producer(dev);
ret = rtnr_check_params(mod, &sourceb->stream, &sinkb->stream);
if (ret)
goto err;
Expand Down
Loading

0 comments on commit c610927

Please sign in to comment.