]> git.alsa-project.org Git - alsa-lib.git/commit
pcm: direct: roll back appl_ptr when mmap_commit fails
authorAndy Saul <asaul@brightsign.biz>
Fri, 20 Nov 2026 15:34:55 +0000 (15:34 +0000)
committerJaroslav Kysela <perex@perex.cz>
Mon, 30 Nov 2026 21:00:35 +0000 (22:00 +0100)
commit9a87ee54bfca5208c0d710aff2de1ad8ccdddf38
treee5a592f0b70521898e4ea389e8d9c6536771faac
parent7647c08e50124b9062d0b214bc20b26f8cf05e0f
pcm: direct: roll back appl_ptr when mmap_commit fails

dmix and dshare forward their appl_ptr in mmap_commit before they
start the timer or sync the hardware pointer. If either step fails,
for example when sync_ptr finds that the buffer ran dry and returns
-EPIPE, the commit returns the error but leaves appl_ptr forwarded.
The frames are never mixed or copied.

A plugin such as softvol above dmix does not forward its own appl_ptr
when the slave commit fails, so the two now differ. The next
snd_pcm_status() aborts in snd_pcm_plugin_status() on

  pcm_plugin.c: snd_pcm_plugin_status: Assertion
  `status->appl_ptr == *pcm->appl.ptr' failed.

The plugin calls avail_update on dmix before it converts and commits,
so this needs the buffer to run dry between those two calls. A thread
preempted inside the plugin's commit while the buffer is nearly empty
is enough.

Move appl_ptr back by the committed size when start_timer or sync_ptr
fails, so a failed commit leaves no trace, as the early check_xrun
return already does.

Closes: https://github.com/alsa-project/alsa-lib/pull/542
Signed-off-by: Andy Saul <asaul@brightsign.biz>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
src/pcm/pcm_dmix.c
src/pcm/pcm_dshare.c