[PATCH 9/9] ASoC: SOF: ipc4-pcm: add delay function support
Jaroslav Kysela
perex at perex.cz
Wed Feb 1 13:44:01 CET 2023
On 01. 02. 23 13:32, Peter Ujfalusi wrote:
> +static snd_pcm_sframes_t sof_ipc4_pcm_delay(struct snd_soc_component *component,
> + struct snd_pcm_substream *substream)
> +{
...
> +
> + /*
> + * Handle 32-bit counter wrap around, which would happen
> + * for a 48khz 2ch stream in 24.855 hours
> + */
> + link_ptr = tmp_ptr & UINT_MAX;
> +
> + host_ptr = substream->runtime->status->hw_ptr;
> +
> + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
> + return host_ptr - link_ptr;
> +
> + return link_ptr - host_ptr;
I don't think that this calculation is fine for the wrap point. The hw_ptr is
in range 0..pcm_boundary not UINT_MAX. Also, you should consider the
underrun/overrun situations. The simple substraction is not enough to handle
this correctly.
Jaroslav
--
Jaroslav Kysela <perex at perex.cz>
Linux Sound Maintainer; ALSA Project; Red Hat, Inc.
More information about the Alsa-devel
mailing list