mirror of https://github.com/thesofproject/sof.git
Audio stream: Add audio_stream_samples_without_wrap_s16/s24/s32 functions
This patch adds functions to retrieve number of PCM samples until source or sink buffer circular wrap need. Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
This commit is contained in:
parent
6d0ecc37cc
commit
c186b41818
|
@ -565,6 +565,54 @@ audio_stream_rewind_bytes_without_wrap(const struct audio_stream *source, const
|
|||
return to_begin;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Calculates numbers of s16 samples to buffer wrap when buffer
|
||||
* is read forward towards end address.
|
||||
* @param source Stream to get information from.
|
||||
* @param ptr Read or write pointer from source
|
||||
* @return Number of data s16 samples until circular wrap need at end
|
||||
*/
|
||||
static inline int
|
||||
audio_stream_samples_without_wrap_s16(const struct audio_stream *source, const void *ptr)
|
||||
{
|
||||
int to_end = (int16_t *)source->end_addr - (int16_t *)ptr;
|
||||
|
||||
assert((intptr_t)source->end_addr >= (intptr_t)ptr);
|
||||
return to_end;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Calculates numbers of s24 samples to buffer wrap when buffer
|
||||
* is read forward towards end address.
|
||||
* @param source Stream to get information from.
|
||||
* @param ptr Read or write pointer from source
|
||||
* @return Number of data s24 samples until circular wrap need at end
|
||||
*/
|
||||
static inline int
|
||||
audio_stream_samples_without_wrap_s24(const struct audio_stream *source, const void *ptr)
|
||||
{
|
||||
int to_end = (int32_t *)source->end_addr - (int32_t *)ptr;
|
||||
|
||||
assert((intptr_t)source->end_addr >= (intptr_t)ptr);
|
||||
return to_end;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Calculates numbers of s32 samples to buffer wrap when buffer
|
||||
* is read forward towards end address.
|
||||
* @param source Stream to get information from.
|
||||
* @param ptr Read or write pointer from source
|
||||
* @return Number of data s32 samples until circular wrap need at end
|
||||
*/
|
||||
static inline int
|
||||
audio_stream_samples_without_wrap_s32(const struct audio_stream *source, const void *ptr)
|
||||
{
|
||||
int to_end = (int32_t *)source->end_addr - (int32_t *)ptr;
|
||||
|
||||
assert((intptr_t)source->end_addr >= (intptr_t)ptr);
|
||||
return to_end;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Calculates numbers of frames to buffer wrap and return
|
||||
* minimum of calculated value.
|
||||
|
|
Loading…
Reference in New Issue