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:
Seppo Ingalsuo 2020-03-03 10:42:44 +02:00 committed by Liam Girdwood
parent 0110241b0d
commit 4230375781
3 changed files with 17 additions and 16 deletions

View File

@ -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); struct dai_data *dd = comp_get_drvdata(dev);
uint32_t bytes = next->elem.size; uint32_t bytes = next->elem.size;
uint32_t sink_bytes; 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; void *buffer_ptr;
comp_dbg(dev, "dai_dma_cb()"); 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 */ /* set up DMA configuration */
config->direction = DMA_DIR_MEM_TO_DEV; config->direction = DMA_DIR_MEM_TO_DEV;
config->src_width = sample_bytes(dd->frame_fmt); config->src_width = get_sample_bytes(dd->frame_fmt);
config->dest_width = sample_bytes(dd->frame_fmt); config->dest_width = config->src_width;
config->cyclic = 1; config->cyclic = 1;
config->irq_disabled = pipeline_is_timer_driven(dev->pipeline); config->irq_disabled = pipeline_is_timer_driven(dev->pipeline);
config->dest_dev = dai_get_handshake(dd->dai, dev->direction, 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->src_width = 4;
config->dest_width = 4; config->dest_width = 4;
} else { } else {
config->src_width = sample_bytes(dd->frame_fmt); config->src_width = get_sample_bytes(dd->frame_fmt);
config->dest_width = 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", comp_info(dev, "dai_capture_params() src_dev = %d stream_id = %d src_width = %d dest_width = %d",
@ -435,8 +435,8 @@ static int dai_params(struct comp_dev *dev,
} }
/* calculate frame size */ /* calculate frame size */
frame_size = frame_bytes(dd->frame_fmt, frame_size = get_frame_bytes(dd->frame_fmt,
dd->local_buffer->stream.channels); dd->local_buffer->stream.channels);
/* calculate period size */ /* calculate period size */
period_bytes = dev->frames * frame_size; period_bytes = dev->frames * frame_size;
@ -671,15 +671,15 @@ static int dai_copy(struct comp_dev *dev)
if (dev->direction == SOF_IPC_STREAM_PLAYBACK) { if (dev->direction == SOF_IPC_STREAM_PLAYBACK) {
src_samples = dd->local_buffer->stream.avail / src_samples = dd->local_buffer->stream.avail /
audio_stream_sample_bytes(&dd->local_buffer->stream); 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) * copy_bytes = MIN(src_samples, sink_samples) *
sample_bytes(dd->frame_fmt); get_sample_bytes(dd->frame_fmt);
} else { } 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 / sink_samples = dd->local_buffer->stream.free /
audio_stream_sample_bytes(&dd->local_buffer->stream); audio_stream_sample_bytes(&dd->local_buffer->stream);
copy_bytes = MIN(src_samples, sink_samples) * copy_bytes = MIN(src_samples, sink_samples) *
sample_bytes(dd->frame_fmt); get_sample_bytes(dd->frame_fmt);
} }
buffer_unlock(dd->local_buffer, flags); buffer_unlock(dd->local_buffer, flags);

View File

@ -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) 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) 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);
} }
/** /**

View File

@ -161,14 +161,15 @@ static inline int32_t sign_extend_s24(int32_t x)
return (x << 8) >> 8; 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; 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__ */ #endif /* __SOF_AUDIO_FORMAT_H__ */