Skip to content

Commit

Permalink
list_first_item(&dev->bsink_list, struct comp_buffer, source_list);
Browse files Browse the repository at this point in the history
 comp_dev_get_first_data_consumer(dev);
  • Loading branch information
marcinszkudlinski committed Sep 13, 2024
1 parent 171a416 commit b0a6637
Show file tree
Hide file tree
Showing 47 changed files with 75 additions and 105 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
13 changes: 5 additions & 8 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 All @@ -472,7 +471,7 @@ static int asrc_dai_find(struct comp_dev *dev, struct comp_data *cd)
do {
sourceb = list_first_item(&dev->bsource_list, struct comp_buffer, sink_list);

dev = sourceb->source;
dev = sourceb->Xsource;

if (!dev) {
comp_err(asrc_dev, "At beginning, no DAI found.");
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
4 changes: 2 additions & 2 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
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
2 changes: 1 addition & 1 deletion src/audio/google/google_rtc_audio_processing.c
Original file line number Diff line number Diff line change
Expand Up @@ -636,7 +636,7 @@ static int google_rtc_audio_processing_prepare(struct processing_module *mod,
cd->ref_comp_buffer = list_first_item(&dev->bsource_list,
struct comp_buffer, sink_list);
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 @@ -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
2 changes: 1 addition & 1 deletion src/audio/module_adapter/module/cadence.c
Original file line number Diff line number Diff line change
Expand Up @@ -778,7 +778,7 @@ cadence_codec_process(struct processing_module *mod,
}

/* do not proceed with processing if not enough free space left in the local buffer */
local_buff = list_first_item(&mod->sink_buffer_list, struct comp_buffer, sink_list);
local_buff = comp_dev_get_first_data_producer(mod);
free_bytes = audio_stream_get_free(&local_buff->stream);
if (free_bytes < output_bytes)
return -ENOSPC;
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/module_adapter/module_adapter.c
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ int module_adapter_prepare(struct comp_dev *dev)
/* Get period_bytes first on prepare(). At this point it is guaranteed that the stream
* parameter from sink buffer is settled, and still prior to all references to period_bytes.
*/
sink = list_first_item(&dev->bsink_list, struct comp_buffer, source_list);
sink = comp_dev_get_first_data_consumer(dev);

mod->period_bytes = audio_stream_period_bytes(&sink->stream, dev->frames);
comp_dbg(dev, "module_adapter_prepare(): got period_bytes = %u", mod->period_bytes);
Expand Down
2 changes: 1 addition & 1 deletion src/audio/module_adapter/module_adapter_ipc3.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ static int module_source_status_count(struct comp_dev *dev, uint32_t status)
struct comp_buffer *source = container_of(blist, struct comp_buffer,
sink_list);

if (source->source && source->source->state == status)
if (source->Xsource && source->Xsource->state == status)
count++;
}

Expand Down
2 changes: 1 addition & 1 deletion src/audio/module_adapter/module_adapter_ipc4.c
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ static bool module_adapter_multi_sink_source_prepare(struct comp_dev *dev)
return true;

/* re-assign the source/sink modules */
mod->sink_comp_buffer = list_first_item(&dev->bsink_list, struct comp_buffer, source_list);
mod->sink_comp_buffer = comp_dev_get_first_data_consumer(dev);
mod->source_comp_buffer = list_first_item(&dev->bsource_list,
struct comp_buffer, sink_list);

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
Loading

0 comments on commit b0a6637

Please sign in to comment.