From 0a7e3a7a0b4dc9b1d63f16a601df9cbacfe127e8 Mon Sep 17 00:00:00 2001 From: Marcin Szkudlinski Date: Mon, 16 Sep 2024 13:50:47 +0200 Subject: [PATCH] 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 --- src/include/sof/audio/component.h | 43 +++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/src/include/sof/audio/component.h b/src/include/sof/audio/component.h index c10b3bf67858..14fa4c0f215b 100644 --- a/src/include/sof/audio/component.h +++ b/src/include/sof/audio/component.h @@ -634,6 +634,49 @@ struct comp_dev { #endif }; +/** + * Get a pointer to a first comp_buffer object providing data to the component + * The procedure will return NULL if there's no data provider + */ +static inline struct comp_buffer *comp_dev_get_first_data_producer(struct comp_dev *component) +{ + return list_is_empty(&component->bsource_list) ? NULL : + list_first_item(&component->bsource_list, struct comp_buffer, sink_list); +} + +/** + * Get a pointer to a next comp_buffer object providing data to the component + * The procedure will return NULL if there're no more data providers + */ +static inline struct comp_buffer *comp_dev_get_next_data_producer(struct comp_dev *component, + struct comp_buffer *producer) +{ + return producer->sink_list.next == &component->bsource_list ? NULL : + list_item(producer->sink_list.next, struct comp_buffer, sink_list); +} + +/** + * Get a pointer to a first comp_buffer object recieving data from the component + * The procedure will return NULL if there's no data consumers + */ +static inline struct comp_buffer *comp_dev_get_first_data_consumer(struct comp_dev *component) +{ + return list_is_empty(&component->bsink_list) ? NULL : + list_first_item(&component->bsink_list, struct comp_buffer, source_list); +} + +/** + * Get a pointer to a next comp_buffer object providing data to the component + * The procedure will return NULL if there're no more data providers + */ +static inline struct comp_buffer *comp_dev_get_next_data_consumer(struct comp_dev *component, + struct comp_buffer *consumer) +{ + return consumer->source_list.next == &component->bsink_list ? NULL : + list_item(consumer->source_list.next, struct comp_buffer, source_list); +} + + /** @}*/ /* Common helper function used internally by the component implementations