<p></p>
<p>><br>
> Calling snd_pcm_avail/delay causes a syscall to the kernel, which<br>
> communicates with the audio hardware, and can therefore be expensive<br>
> on some cards.</p>
<p><a href="https://git.kernel.org/cgit/linux/kernel/git/tiwai/sound.git/commit/sound/soc/soc-generic-dmaengine-pcm.c?id=478028e088d6a94666d8a776be2cd2291faf3bbd">https://git.kernel.org/cgit/linux/kernel/git/tiwai/sound.git/commit/sound/soc/soc-generic-dmaengine-pcm.c?id=478028e088d6a94666d8a776be2cd2291faf3bbd</a></p>
<p>If dmaengine_pcm_can_report_residue() is true, it won't take too long as sound card just read the value from hardware register , the uncertainity of this position is just DMA brust size, otherwise the uncertainity is one period size.</p>
<p>You can simulate those sound card without this capability by forcing your hda driver to report hwptr in period size granularity</p>
<p>static snd_pcm_uframes_t azx_pcm_pointer(struct snd_pcm_substream *substream)<br>
{<br>
struct azx_pcm *apcm = snd_pcm_substream_chip(substream);<br>
struct azx *chip = apcm->chip;<br>
struct azx_dev *azx_dev = get_azx_dev(substream);<br>
- return bytes_to_frames(substream->runtime,<br>
azx_get_position(chip, azx_dev));<br>
+ return bytes_to_frames(substream->runtime,<br>
azx_get_position(chip, azx_dev)) / substream->runtime->period_size * substream->runtime->period_size ;<br>
}</p>
<p>Pulseaudio should not enable timer scheduling when<br>
dmaengine_pcm_can_report_residue() is false</p>