From: Joonho Lee <[email protected]> The indirect playback transfer helper samples runtime->control->appl_ptr internally. A driver that needs to refill already committed data from a pointer callback cannot pass the application-pointer snapshot used for ACK validation.
Add snd_pcm_indirect_playback_transfer_appl_ptr() so callers can supply that snapshot. Keep snd_pcm_indirect_playback_transfer() as a wrapper that samples the runtime pointer as before, preserving existing callers. The explicit-pointer form lets virtio refill accepted data without accepting new application progress while the ALSA buffer-access gate is closed. Assisted-by: LLM Signed-off-by: Joonho Lee <[email protected]> --- include/sound/pcm-indirect.h | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/include/sound/pcm-indirect.h b/include/sound/pcm-indirect.h index 98e06ea73b2b..ed73bf8ef423 100644 --- a/include/sound/pcm-indirect.h +++ b/include/sound/pcm-indirect.h @@ -28,15 +28,17 @@ typedef void (*snd_pcm_indirect_copy_t)(struct snd_pcm_substream *substream, struct snd_pcm_indirect *rec, size_t bytes); /* - * helper function for playback ack callback + * Playback transfer using a caller-supplied application pointer snapshot. + * Passing rec->appl_ptr refills previously accepted data without accepting + * additional application progress. */ static inline int -snd_pcm_indirect_playback_transfer(struct snd_pcm_substream *substream, - struct snd_pcm_indirect *rec, - snd_pcm_indirect_copy_t copy) +snd_pcm_indirect_playback_transfer_appl_ptr(struct snd_pcm_substream *substream, + struct snd_pcm_indirect *rec, + snd_pcm_indirect_copy_t copy, + snd_pcm_uframes_t appl_ptr) { struct snd_pcm_runtime *runtime = substream->runtime; - snd_pcm_uframes_t appl_ptr = runtime->control->appl_ptr; snd_pcm_sframes_t diff = appl_ptr - rec->appl_ptr; int qsize; @@ -74,6 +76,18 @@ snd_pcm_indirect_playback_transfer(struct snd_pcm_substream *substream, return 0; } +/* Preserve the application pointer sampling of the ordinary ACK helper. */ +static inline int +snd_pcm_indirect_playback_transfer(struct snd_pcm_substream *substream, + struct snd_pcm_indirect *rec, + snd_pcm_indirect_copy_t copy) +{ + snd_pcm_uframes_t appl_ptr = substream->runtime->control->appl_ptr; + + return snd_pcm_indirect_playback_transfer_appl_ptr(substream, rec, copy, + appl_ptr); +} + /* * helper function for playback pointer callback * ptr = current byte pointer -- Git-157)
