mirror of https://github.com/thesofproject/sof.git
buffer: add helper function for processing wrapped buffer
Adds helper function for easier processing of wrapped buffer. Processing modules should switch to this function instead of directly using read and write pointers of buffer. Signed-off-by: Tomasz Lauda <tomasz.lauda@linux.intel.com>
This commit is contained in:
parent
2a863143e8
commit
a3eaaf8b2d
|
@ -96,6 +96,24 @@ struct comp_buffer {
|
||||||
buffer->sink = comp; \
|
buffer->sink = comp; \
|
||||||
} while (0) \
|
} while (0) \
|
||||||
|
|
||||||
|
#define buffer_read_frag(buffer, idx, size) \
|
||||||
|
buffer_get_frag(buffer, buffer->r_ptr, idx, size)
|
||||||
|
|
||||||
|
#define buffer_read_frag_s16(buffer, idx) \
|
||||||
|
buffer_get_frag(buffer, buffer->r_ptr, idx, sizeof(int16_t))
|
||||||
|
|
||||||
|
#define buffer_read_frag_s32(buffer, idx) \
|
||||||
|
buffer_get_frag(buffer, buffer->r_ptr, idx, sizeof(int32_t))
|
||||||
|
|
||||||
|
#define buffer_write_frag(buffer, idx, size) \
|
||||||
|
buffer_get_frag(buffer, buffer->w_ptr, idx, size)
|
||||||
|
|
||||||
|
#define buffer_write_frag_s16(buffer, idx) \
|
||||||
|
buffer_get_frag(buffer, buffer->w_ptr, idx, sizeof(int16_t))
|
||||||
|
|
||||||
|
#define buffer_write_frag_s32(buffer, idx) \
|
||||||
|
buffer_get_frag(buffer, buffer->w_ptr, idx, sizeof(int32_t))
|
||||||
|
|
||||||
typedef void (*cache_buff_op)(struct comp_buffer *);
|
typedef void (*cache_buff_op)(struct comp_buffer *);
|
||||||
|
|
||||||
/* pipeline buffer creation and destruction */
|
/* pipeline buffer creation and destruction */
|
||||||
|
@ -197,4 +215,16 @@ static inline int buffer_set_size(struct comp_buffer *buffer, uint32_t size)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline void *buffer_get_frag(struct comp_buffer *buffer, void *ptr,
|
||||||
|
uint32_t idx, uint32_t size)
|
||||||
|
{
|
||||||
|
void *current = ptr + (idx * size);
|
||||||
|
|
||||||
|
/* check for pointer wrap */
|
||||||
|
if (current >= buffer->end_addr)
|
||||||
|
current = buffer->addr + (current - buffer->end_addr);
|
||||||
|
|
||||||
|
return current;
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue