Skip to content

Commit e48aab8

Browse files
buf: use API for iteration bsource_list in components
this commit changes all components to use comp_dev_for_each_producer for iteration through bsource_list pipeline code, like module adapter or ipc helpers was omitted intentionally Signed-off-by: Marcin Szkudlinski <marcin.szkudlinski@intel.com>
1 parent f42fb8b commit e48aab8

File tree

6 files changed

+18
-38
lines changed

6 files changed

+18
-38
lines changed

src/audio/mixer/mixer.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -163,16 +163,15 @@ static int mixer_reset(struct processing_module *mod)
163163
{
164164
struct mixer_data *md = module_get_private_data(mod);
165165
struct comp_dev *dev = mod->dev;
166-
struct list_item *blist;
167166
int dir = dev->pipeline->source_comp->direction;
168167

169168
comp_dbg(dev, "mixer_reset()");
170169

171170
if (dir == SOF_IPC_STREAM_PLAYBACK) {
172-
list_for_item(blist, &dev->bsource_list) {
171+
struct comp_buffer *source;
172+
173+
comp_dev_for_each_producer(dev, source) {
173174
/* FIXME: this is racy and implicitly protected by serialised IPCs */
174-
struct comp_buffer *source = container_of(blist, struct comp_buffer,
175-
sink_list);
176175
bool stop = false;
177176

178177
if (source->source && source->source->state > COMP_STATE_READY)
@@ -214,15 +213,15 @@ static int mixer_prepare(struct processing_module *mod,
214213
struct mixer_data *md = module_get_private_data(mod);
215214
struct comp_dev *dev = mod->dev;
216215
struct comp_buffer *sink;
217-
struct list_item *blist;
218216

219217
sink = comp_dev_get_first_data_consumer(dev);
220218
md->mix_func = mixer_get_processing_function(dev, sink);
221219
mixer_set_frame_alignment(&sink->stream);
222220

223221
/* check each mixer source state */
224-
list_for_item(blist, &dev->bsource_list) {
225-
struct comp_buffer *source;
222+
struct comp_buffer *source;
223+
224+
comp_dev_for_each_producer(dev, source) {
226225
bool stop;
227226

228227
/*
@@ -233,7 +232,6 @@ static int mixer_prepare(struct processing_module *mod,
233232
* preparing the mixer, so they shouldn't touch it until we're
234233
* done.
235234
*/
236-
source = container_of(blist, struct comp_buffer, sink_list);
237235
mixer_set_frame_alignment(&source->stream);
238236
stop = source->source && (source->source->state == COMP_STATE_PAUSED ||
239237
source->source->state == COMP_STATE_ACTIVE);

src/audio/mux/mux.c

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,6 @@ static int mux_process(struct processing_module *mod,
289289
struct comp_data *cd = module_get_private_data(mod);
290290
struct comp_dev *dev = mod->dev;
291291
struct comp_buffer *source;
292-
struct list_item *clist;
293292
const struct audio_stream *sources_stream[MUX_MAX_STREAMS] = { NULL };
294293
int frames = 0;
295294
int sink_bytes;
@@ -300,8 +299,7 @@ static int mux_process(struct processing_module *mod,
300299

301300
/* align source streams with their respective configurations */
302301
j = 0;
303-
list_for_item(clist, &dev->bsource_list) {
304-
source = container_of(clist, struct comp_buffer, sink_list);
302+
comp_dev_for_each_producer(dev, source) {
305303
if (source->source->state == dev->state) {
306304
if (frames)
307305
frames = MIN(frames, input_buffers[j].size);
@@ -332,8 +330,7 @@ static int mux_process(struct processing_module *mod,
332330

333331
/* Update consumed and produced */
334332
j = 0;
335-
list_for_item(clist, &dev->bsource_list) {
336-
source = container_of(clist, struct comp_buffer, sink_list);
333+
comp_dev_for_each_producer(dev, source) {
337334
if (source->source->state == dev->state)
338335
mod->input_buffers[j].consumed = source_bytes;
339336
j++;
@@ -344,17 +341,15 @@ static int mux_process(struct processing_module *mod,
344341

345342
static int mux_reset(struct processing_module *mod)
346343
{
347-
struct list_item *blist;
344+
struct comp_buffer *source;
348345
struct comp_data *cd = module_get_private_data(mod);
349346
struct comp_dev *dev = mod->dev;
350347
int dir = dev->pipeline->source_comp->direction;
351348

352349
comp_dbg(dev, "mux_reset()");
353350

354351
if (dir == SOF_IPC_STREAM_PLAYBACK) {
355-
list_for_item(blist, &dev->bsource_list) {
356-
struct comp_buffer *source = container_of(blist, struct comp_buffer,
357-
sink_list);
352+
comp_dev_for_each_producer(dev, source) {
358353
int state = source->source->state;
359354

360355
/* only mux the sources with the same state with mux */
@@ -434,9 +429,6 @@ static int mux_set_config(struct processing_module *mod, uint32_t config_id,
434429

435430
static int demux_trigger(struct processing_module *mod, int cmd)
436431
{
437-
struct list_item *li;
438-
struct comp_buffer *b;
439-
440432
/* Check for cross-pipeline sinks: in general foreign
441433
* pipelines won't be started synchronously with ours (it's
442434
* under control of host software), so output can't be
@@ -446,8 +438,9 @@ static int demux_trigger(struct processing_module *mod, int cmd)
446438
* themselves.
447439
*/
448440
if (cmd == COMP_TRIGGER_PRE_START) {
449-
list_for_item(li, &mod->dev->bsink_list) {
450-
b = container_of(li, struct comp_buffer, source_list);
441+
struct comp_buffer *b;
442+
443+
comp_dev_for_each_producer(mod->dev, b) {
451444
if (b->sink->pipeline != mod->dev->pipeline)
452445
audio_stream_set_overrun(&b->stream, true);
453446
}

src/audio/mux/mux_ipc4.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ static void set_mux_params(struct processing_module *mod)
7474
struct comp_data *cd = module_get_private_data(mod);
7575
struct comp_dev *dev = mod->dev;
7676
struct comp_buffer *sink, *source;
77-
struct list_item *source_list;
7877
int j;
7978

8079
params->direction = dev->direction;
@@ -106,9 +105,7 @@ static void set_mux_params(struct processing_module *mod)
106105
if (!list_is_empty(&dev->bsource_list)) {
107106
struct ipc4_audio_format *audio_fmt;
108107

109-
list_for_item(source_list, &dev->bsource_list)
110-
{
111-
source = container_of(source_list, struct comp_buffer, sink_list);
108+
comp_dev_for_each_producer(dev, source) {
112109
j = buf_get_id(source);
113110
cd->config.streams[j].pipeline_id = buffer_pipeline_id(source);
114111
if (j == BASE_CFG_QUEUED_ID)

src/audio/smart_amp/smart_amp.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -731,7 +731,6 @@ static int smart_amp_resolve_mod_fmt(struct comp_dev *dev, uint32_t least_req_de
731731
static int smart_amp_prepare(struct comp_dev *dev)
732732
{
733733
struct smart_amp_data *sad = comp_get_drvdata(dev);
734-
struct list_item *blist;
735734
uint16_t ff_src_fmt, fb_src_fmt, resolved_mod_fmt;
736735
uint32_t least_req_depth;
737736
uint32_t rate;
@@ -744,10 +743,9 @@ static int smart_amp_prepare(struct comp_dev *dev)
744743
return ret;
745744

746745
/* searching for stream and feedback source buffers */
747-
list_for_item(blist, &dev->bsource_list) {
748-
struct comp_buffer *source_buffer = container_of(blist, struct comp_buffer,
749-
sink_list);
746+
struct comp_buffer *source_buffer;
750747

748+
comp_dev_for_each_producer(dev, source_buffer) {
751749
if (source_buffer->source->ipc_config.type == SOF_COMP_DEMUX)
752750
sad->feedback_buf = source_buffer;
753751
else

src/probe/probe.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1061,13 +1061,11 @@ static bool probe_purpose_needs_ext_dma(uint32_t purpose)
10611061
static struct comp_buffer *ipc4_get_buffer(struct ipc_comp_dev *dev, probe_point_id_t probe_point)
10621062
{
10631063
struct comp_buffer *buf;
1064-
struct list_item *source_list;
10651064
unsigned int queue_id;
10661065

10671066
switch (probe_point.fields.type) {
10681067
case PROBE_TYPE_INPUT:
1069-
list_for_item(source_list, &dev->cd->bsource_list) {
1070-
buf = container_of(source_list, struct comp_buffer, sink_list);
1068+
comp_dev_for_each_producer(dev->cd, buf) {
10711069
queue_id = IPC4_SRC_QUEUE_ID(buf_get_id(buf));
10721070

10731071
if (queue_id == probe_point.fields.index)

src/samples/audio/smart_amp_test_ipc3.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,6 @@ static int smart_amp_prepare(struct comp_dev *dev)
487487
{
488488
struct smart_amp_data *sad = comp_get_drvdata(dev);
489489
struct comp_buffer *source_buffer;
490-
struct list_item *blist;
491490
int ret;
492491

493492
comp_info(dev, "smart_amp_prepare()");
@@ -500,10 +499,7 @@ static int smart_amp_prepare(struct comp_dev *dev)
500499
return PPL_STATUS_PATH_STOP;
501500

502501
/* searching for stream and feedback source buffers */
503-
list_for_item(blist, &dev->bsource_list) {
504-
source_buffer = container_of(blist, struct comp_buffer,
505-
sink_list);
506-
502+
comp_dev_for_each_producer(dev, source_buffer) {
507503
/* FIXME: how often can this loop be run? */
508504
if (source_buffer->source->ipc_config.type == SOF_COMP_DEMUX)
509505
sad->feedback_buf = source_buffer;

0 commit comments

Comments
 (0)