Skip to content

Commit 1b5d1fe

Browse files
buf: add API functions for accessing comp_buffer lists
this commit adds functions for accessing sink_list and source_list from comp_buffer structure Signed-off-by: Marcin Szkudlinski <marcin.szkudlinski@intel.com>
1 parent 15062f0 commit 1b5d1fe

1 file changed

Lines changed: 58 additions & 0 deletions

File tree

src/include/sof/audio/component.h

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -634,6 +634,64 @@ struct comp_dev {
634634
#endif
635635
};
636636

637+
/**
638+
* Get a pointer to a first comp_buffer object providing data to the component
639+
* The procedure will return NULL if there's no data provider
640+
*/
641+
static inline struct comp_buffer *comp_dev_get_first_data_producer(struct comp_dev *component)
642+
{
643+
return list_is_empty(&component->bsource_list) ? NULL :
644+
list_first_item(&component->bsource_list, struct comp_buffer, sink_list);
645+
}
646+
647+
/**
648+
* Get a pointer to a next comp_buffer object providing data to the component
649+
* The procedure will return NULL if there're no more data providers
650+
*/
651+
static inline struct comp_buffer *comp_dev_get_next_data_producer(struct comp_dev *component,
652+
struct comp_buffer *producer)
653+
{
654+
return producer->sink_list.next == &component->bsource_list ? NULL :
655+
list_item(producer->sink_list.next, struct comp_buffer, sink_list);
656+
}
657+
658+
/**
659+
* Get a pointer to a first comp_buffer object receiving data from the component
660+
* The procedure will return NULL if there's no data consumers
661+
*/
662+
static inline struct comp_buffer *comp_dev_get_first_data_consumer(struct comp_dev *component)
663+
{
664+
return list_is_empty(&component->bsink_list) ? NULL :
665+
list_first_item(&component->bsink_list, struct comp_buffer, source_list);
666+
}
667+
668+
/**
669+
* Get a pointer to a next comp_buffer object receiving data from the component
670+
* The procedure will return NULL if there're no more data consumers
671+
*/
672+
static inline struct comp_buffer *comp_dev_get_next_data_consumer(struct comp_dev *component,
673+
struct comp_buffer *consumer)
674+
{
675+
return consumer->source_list.next == &component->bsink_list ? NULL :
676+
list_item(consumer->source_list.next, struct comp_buffer, source_list);
677+
}
678+
679+
/*
680+
* a macro for easy iteration through component's list of producers
681+
*/
682+
#define comp_dev_for_each_producer(_dev, _producer) \
683+
for (_producer = comp_dev_get_first_data_producer(_dev); \
684+
_producer != NULL; \
685+
_producer = comp_dev_get_next_data_producer(_dev, _producer))
686+
687+
/*
688+
* a macro for easy iteration through component's list of consumers
689+
*/
690+
#define comp_dev_for_each_consumer(_dev, _consumer) \
691+
for (_consumer = comp_dev_get_first_data_consumer(_dev); \
692+
_consumer != NULL; \
693+
_consumer = comp_dev_get_next_data_consumer(_dev, _consumer))
694+
637695
/** @}*/
638696

639697
/* Common helper function used internally by the component implementations

0 commit comments

Comments
 (0)