 
            
            
            
            
                1 Feb
                
                    2023
                
            
            
                1 Feb
                
                '23
                
            
            
            
        
    
                1:44 p.m.
            
        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@perex.cz
Linux Sound Maintainer; ALSA Project; Red Hat, Inc.