Add an API to get the size of an individual sample in bytes.
Signed-off-by: Liam Girdwood liam.r.girdwood@linux.intel.com --- src/include/reef/audio/component.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
diff --git a/src/include/reef/audio/component.h b/src/include/reef/audio/component.h index 5d15fdb..f25ad3d 100644 --- a/src/include/reef/audio/component.h +++ b/src/include/reef/audio/component.h @@ -335,6 +335,21 @@ static inline uint32_t comp_frame_bytes(struct comp_dev *dev) } }
+static inline uint32_t comp_sample_bytes(struct comp_dev *dev) +{ + /* calculate period size based on params */ + switch (dev->params.frame_fmt) { + case SOF_IPC_FRAME_S16_LE: + return 2; + case SOF_IPC_FRAME_S24_4LE: + case SOF_IPC_FRAME_S32_LE: + case SOF_IPC_FRAME_FLOAT: + return 4; + default: + return 0; + } +} + /* XRUN handling */ static inline void comp_underrun(struct comp_dev *dev, struct comp_buffer *source, uint32_t copy_bytes, uint32_t min_bytes)