Complain loudly in trace if we have components overruning or underruning buffers. Components should check buffer free/avail before use.
Signed-off-by: Liam Girdwood liam.r.girdwood@linux.intel.com --- src/include/reef/audio/buffer.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
diff --git a/src/include/reef/audio/buffer.h b/src/include/reef/audio/buffer.h index 55e9de1..9394d29 100644 --- a/src/include/reef/audio/buffer.h +++ b/src/include/reef/audio/buffer.h @@ -81,6 +81,14 @@ void buffer_free(struct comp_buffer *buffer); static inline void comp_update_buffer_produce(struct comp_buffer *buffer, uint32_t bytes) { + /* complain loudly if component tries to overrun buffer + * components MUST check for free space first !! */ + if (bytes > buffer->free) { + trace_buffer_error("Xxo"); + trace_value(buffer->ipc_buffer.comp.id); + return; + } + buffer->w_ptr += bytes;
/* check for pointer wrap */ @@ -107,6 +115,14 @@ static inline void comp_update_buffer_produce(struct comp_buffer *buffer, static inline void comp_update_buffer_consume(struct comp_buffer *buffer, uint32_t bytes) { + /* complain loudly if component tries to underrun buffer + * components MUST check for avail space first !! */ + if (buffer->avail < bytes) { + trace_buffer_error("Xxu"); + trace_value(buffer->ipc_buffer.comp.id); + return; + } + buffer->r_ptr += bytes;
/* check for pointer wrap */