Re: [PATCH 9/9] ASoC: SOF: ipc4-pcm: add delay function support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxx>
Linux Sound Maintainer; ALSA Project; Red Hat, Inc.




[Index of Archives]     [ALSA User]     [Linux Audio Users]     [Pulse Audio]     [Kernel Archive]     [Asterisk PBX]     [Photo Sharing]     [Linux Sound]     [Video 4 Linux]     [Gimp]     [Yosemite News]

  Powered by Linux