mirror of https://github.com/thesofproject/sof.git
Rename sample_bytes() and frame_bytes() to avoid variables shadowing
The two functions in sof/audio/format.h are renamed to more descriptive get_sample_bytes() and get_frame_bytes() to avoid potentially same name variables to shadow the inline functions defined in the header. The shadowing happened in component ASRC. The DAI component and another header audio_stream.h uses these functions and needed minor edits. Reported-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
This commit is contained in:
parent
0110241b0d
commit
4230375781
|
@ -66,7 +66,7 @@ static void dai_dma_cb(void *arg, enum notify_id type, void *data)
|
|||
struct dai_data *dd = comp_get_drvdata(dev);
|
||||
uint32_t bytes = next->elem.size;
|
||||
uint32_t sink_bytes;
|
||||
uint32_t samples = bytes / sample_bytes(dd->frame_fmt);
|
||||
uint32_t samples = bytes / get_sample_bytes(dd->frame_fmt);
|
||||
void *buffer_ptr;
|
||||
|
||||
comp_dbg(dev, "dai_dma_cb()");
|
||||
|
@ -275,8 +275,8 @@ static int dai_playback_params(struct comp_dev *dev, uint32_t period_bytes,
|
|||
|
||||
/* set up DMA configuration */
|
||||
config->direction = DMA_DIR_MEM_TO_DEV;
|
||||
config->src_width = sample_bytes(dd->frame_fmt);
|
||||
config->dest_width = sample_bytes(dd->frame_fmt);
|
||||
config->src_width = get_sample_bytes(dd->frame_fmt);
|
||||
config->dest_width = config->src_width;
|
||||
config->cyclic = 1;
|
||||
config->irq_disabled = pipeline_is_timer_driven(dev->pipeline);
|
||||
config->dest_dev = dai_get_handshake(dd->dai, dev->direction,
|
||||
|
@ -340,8 +340,8 @@ static int dai_capture_params(struct comp_dev *dev, uint32_t period_bytes,
|
|||
config->src_width = 4;
|
||||
config->dest_width = 4;
|
||||
} else {
|
||||
config->src_width = sample_bytes(dd->frame_fmt);
|
||||
config->dest_width = sample_bytes(dd->frame_fmt);
|
||||
config->src_width = get_sample_bytes(dd->frame_fmt);
|
||||
config->dest_width = config->src_width;
|
||||
}
|
||||
|
||||
comp_info(dev, "dai_capture_params() src_dev = %d stream_id = %d src_width = %d dest_width = %d",
|
||||
|
@ -435,7 +435,7 @@ static int dai_params(struct comp_dev *dev,
|
|||
}
|
||||
|
||||
/* calculate frame size */
|
||||
frame_size = frame_bytes(dd->frame_fmt,
|
||||
frame_size = get_frame_bytes(dd->frame_fmt,
|
||||
dd->local_buffer->stream.channels);
|
||||
|
||||
/* calculate period size */
|
||||
|
@ -671,15 +671,15 @@ static int dai_copy(struct comp_dev *dev)
|
|||
if (dev->direction == SOF_IPC_STREAM_PLAYBACK) {
|
||||
src_samples = dd->local_buffer->stream.avail /
|
||||
audio_stream_sample_bytes(&dd->local_buffer->stream);
|
||||
sink_samples = free_bytes / sample_bytes(dd->frame_fmt);
|
||||
sink_samples = free_bytes / get_sample_bytes(dd->frame_fmt);
|
||||
copy_bytes = MIN(src_samples, sink_samples) *
|
||||
sample_bytes(dd->frame_fmt);
|
||||
get_sample_bytes(dd->frame_fmt);
|
||||
} else {
|
||||
src_samples = avail_bytes / sample_bytes(dd->frame_fmt);
|
||||
src_samples = avail_bytes / get_sample_bytes(dd->frame_fmt);
|
||||
sink_samples = dd->local_buffer->stream.free /
|
||||
audio_stream_sample_bytes(&dd->local_buffer->stream);
|
||||
copy_bytes = MIN(src_samples, sink_samples) *
|
||||
sample_bytes(dd->frame_fmt);
|
||||
get_sample_bytes(dd->frame_fmt);
|
||||
}
|
||||
|
||||
buffer_unlock(dd->local_buffer, flags);
|
||||
|
|
|
@ -119,7 +119,7 @@ audio_stream_get_copy_bytes(const struct audio_stream *source,
|
|||
*/
|
||||
static inline uint32_t audio_stream_frame_bytes(const struct audio_stream *buf)
|
||||
{
|
||||
return frame_bytes(buf->frame_fmt, buf->channels);
|
||||
return get_frame_bytes(buf->frame_fmt, buf->channels);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -129,7 +129,7 @@ static inline uint32_t audio_stream_frame_bytes(const struct audio_stream *buf)
|
|||
*/
|
||||
static inline uint32_t audio_stream_sample_bytes(const struct audio_stream *buf)
|
||||
{
|
||||
return sample_bytes(buf->frame_fmt);
|
||||
return get_sample_bytes(buf->frame_fmt);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -161,14 +161,15 @@ static inline int32_t sign_extend_s24(int32_t x)
|
|||
return (x << 8) >> 8;
|
||||
}
|
||||
|
||||
static inline uint32_t sample_bytes(enum sof_ipc_frame fmt)
|
||||
static inline uint32_t get_sample_bytes(enum sof_ipc_frame fmt)
|
||||
{
|
||||
return fmt == SOF_IPC_FRAME_S16_LE ? 2 : 4;
|
||||
}
|
||||
|
||||
static inline uint32_t frame_bytes(enum sof_ipc_frame fmt, uint32_t channels)
|
||||
static inline uint32_t get_frame_bytes(enum sof_ipc_frame fmt,
|
||||
uint32_t channels)
|
||||
{
|
||||
return sample_bytes(fmt) * channels;
|
||||
return get_sample_bytes(fmt) * channels;
|
||||
}
|
||||
|
||||
#endif /* __SOF_AUDIO_FORMAT_H__ */
|
||||
|
|
Loading…
Reference in New Issue