bcm2835: interpolate audio delay
authorwm4 <wm4@nowhere>
Wed, 13 Jan 2016 18:44:47 +0000 (19:44 +0100)
committerpopcornmix <popcornmix@gmail.com>
Mon, 13 May 2019 23:08:02 +0000 (00:08 +0100)
commite800c16c1aeff9ae18b65fdf2c4a24600b558497
tree098c93b52a59cd9f40f3de9c48915abfc9c94b22
parenta88c3a3a52578c53cf23c0f80e7e4c0418d2765a
bcm2835: interpolate audio delay

It appears the GPU only sends us a message all 10ms to update
the playback progress. Other than this, the playback position
(what SNDRV_PCM_IOCTL_DELAY will return) is not updated at all.
Userspace will see jitter up to 10ms in the audio position.

Make this a bit nicer for userspace by interpolating the
position using the CPU clock.

I'm not sure if setting snd_pcm_runtime.delay is the right
approach for this. Or if there is maybe an already existing
mechanism for position interpolation in the ALSA core.

I only set SNDRV_PCM_INFO_BATCH because this appears to remove
at least one situation snd_pcm_runtime.delay is used, so I have
to worry less in which place I have to update this field, or
how it interacts with the rest of ALSA.

In the future, it might be nice to use VC_AUDIO_MSG_TYPE_LATENCY.
One problem is that it requires sending a videocore message, and
waiting for a reply, which could make the implementation much
harder due to locking and synchronization requirements.
drivers/staging/vc04_services/bcm2835-audio/bcm2835-pcm.c
drivers/staging/vc04_services/bcm2835-audio/bcm2835.h