Skip to content

Commit b96a987

Browse files
fix to tools
1 parent 0e7bb6d commit b96a987

File tree

1 file changed

+26
-12
lines changed

1 file changed

+26
-12
lines changed

src/include/sof/audio/component.h

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -649,6 +649,7 @@ static inline struct comp_buffer *comp_dev_get_first_data_producer(struct comp_d
649649
/**
650650
* Get a pointer to the next comp_buffer object providing data to the component
651651
* The function will return NULL if there're no more data providers
652+
* _save version also checks if producer != NULL
652653
*/
653654
static inline struct comp_buffer *comp_dev_get_next_data_producer(struct comp_dev *component,
654655
struct comp_buffer *producer)
@@ -657,6 +658,12 @@ static inline struct comp_buffer *comp_dev_get_next_data_producer(struct comp_de
657658
list_item(producer->sink_list.next, struct comp_buffer, sink_list);
658659
}
659660

661+
static inline struct comp_buffer *comp_dev_get_next_data_producer_safe(struct comp_dev *component,
662+
struct comp_buffer *producer)
663+
{
664+
return producer ? comp_dev_get_next_data_producer(component, producer) : NULL;
665+
}
666+
660667
/**
661668
* Get a pointer to the first comp_buffer object receiving data from the component
662669
* The function will return NULL if there's no data consumers
@@ -670,6 +677,7 @@ static inline struct comp_buffer *comp_dev_get_first_data_consumer(struct comp_d
670677
/**
671678
* Get a pointer to the next comp_buffer object receiving data from the component
672679
* The function will return NULL if there're no more data consumers
680+
* _safe version also checks if consumer is != NULL
673681
*/
674682
static inline struct comp_buffer *comp_dev_get_next_data_consumer(struct comp_dev *component,
675683
struct comp_buffer *consumer)
@@ -678,6 +686,12 @@ static inline struct comp_buffer *comp_dev_get_next_data_consumer(struct comp_de
678686
list_item(consumer->source_list.next, struct comp_buffer, source_list);
679687
}
680688

689+
static inline struct comp_buffer *comp_dev_get_next_data_consumer_safe(struct comp_dev *component,
690+
struct comp_buffer *consumer)
691+
{
692+
return consumer ? comp_dev_get_next_data_consumer(component, consumer) : NULL;
693+
}
694+
681695
/*
682696
* a macro for easy iteration through component's list of producers
683697
*/
@@ -692,12 +706,12 @@ static inline struct comp_buffer *comp_dev_get_next_data_consumer(struct comp_de
692706
*
693707
* additional "safe storage" pointer to struct comp_buffer must be provided
694708
*/
695-
#define comp_dev_for_each_producer_safe(_dev, _producer, _next_producer) \
696-
for (_producer = comp_dev_get_first_data_producer(_dev), \
697-
_next_producer = comp_dev_get_next_data_producer(_dev, _producer); \
698-
_producer != NULL; \
699-
_producer = _next_producer, \
700-
_next_producer = comp_dev_get_next_data_producer(_dev, _producer))
709+
#define comp_dev_for_each_producer_safe(_dev, _producer, _next_producer) \
710+
for (_producer = comp_dev_get_first_data_producer(_dev), \
711+
_next_producer = comp_dev_get_next_data_producer_safe(_dev, _producer); \
712+
_producer != NULL; \
713+
_producer = _next_producer, \
714+
_next_producer = comp_dev_get_next_data_producer_safe(_dev, _producer))
701715

702716
/*
703717
* a macro for easy iteration through component's list of consumers
@@ -713,12 +727,12 @@ static inline struct comp_buffer *comp_dev_get_next_data_consumer(struct comp_de
713727
*
714728
* additional "safe storage" pointer to struct comp_buffer must be provided
715729
*/
716-
#define comp_dev_for_each_consumer_safe(_dev, _consumer, _next_consumer) \
717-
for (_consumer = comp_dev_get_first_data_consumer(_dev), \
718-
_next_consumer = comp_dev_get_next_data_consumer(_dev, _consumer); \
719-
_consumer != NULL; \
720-
_consumer = _next_consumer, \
721-
_next_consumer = comp_dev_get_next_data_consumer(_dev, _consumer))
730+
#define comp_dev_for_each_consumer_safe(_dev, _consumer, _next_consumer) \
731+
for (_consumer = comp_dev_get_first_data_consumer(_dev), \
732+
_next_consumer = comp_dev_get_next_data_consumer_safe(_dev, _consumer); \
733+
_consumer != NULL; \
734+
_consumer = _next_consumer, \
735+
_next_consumer = comp_dev_get_next_data_consumer_safe(_dev, _consumer))
722736

723737
/** @}*/
724738

0 commit comments

Comments
 (0)