buffer: use an accessor to read struct audio_stream::valid_sample_fmt

This patch adds audio_stream_get_valid_fmt() to read
struct audio_stream::valid_sample_fmt and converts all users. Apart
from hiding internals of the structure, it also enforces the use of
the __sparse_cache annotation.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
This commit is contained in:
Guennadi Liakhovetski 2023-04-21 14:59:02 +02:00 committed by Liam Girdwood
parent 017b8ebcde
commit a25f098b72
3 changed files with 8 additions and 2 deletions

View File

@ -699,7 +699,7 @@ static int mixin_prepare(struct processing_module *mod)
sink = list_first_item(&dev->bsink_list, struct comp_buffer, source_list); sink = list_first_item(&dev->bsink_list, struct comp_buffer, source_list);
sink_c = buffer_acquire(sink); sink_c = buffer_acquire(sink);
fmt = sink_c->stream.valid_sample_fmt; fmt = audio_stream_get_valid_fmt(&sink_c->stream);
buffer_release(sink_c); buffer_release(sink_c);
/* currently inactive so setup mixer */ /* currently inactive so setup mixer */

View File

@ -1190,7 +1190,7 @@ static vol_zc_func vol_get_zc_function(struct comp_dev *dev,
/* map the zc function to frame format */ /* map the zc function to frame format */
for (i = 0; i < ARRAY_SIZE(zc_func_map); i++) { for (i = 0; i < ARRAY_SIZE(zc_func_map); i++) {
if (sinkb->stream.valid_sample_fmt == zc_func_map[i].frame_fmt) if (audio_stream_get_valid_fmt(&sinkb->stream) == zc_func_map[i].frame_fmt)
return zc_func_map[i].func; return zc_func_map[i].func;
} }

View File

@ -118,6 +118,12 @@ static inline enum sof_ipc_frame audio_stream_get_frm_fmt(
return buf->frame_fmt; return buf->frame_fmt;
} }
static inline enum sof_ipc_frame audio_stream_get_valid_fmt(
const struct audio_stream __sparse_cache *buf)
{
return buf->valid_sample_fmt;
}
/** /**
* Retrieves readable address of a sample at specified index (see versions of * Retrieves readable address of a sample at specified index (see versions of
* this macro specialized for various sample types). * this macro specialized for various sample types).