]> git.alsa-project.org Git - alsa-lib.git/commit
pcm: direct: Improved suspend/resume support
authorTakashi Iwai <tiwai@suse.de>
Thu, 3 Mar 2022 14:09:19 +0000 (15:09 +0100)
committerTakashi Iwai <tiwai@suse.de>
Thu, 10 Mar 2022 11:58:51 +0000 (12:58 +0100)
commitb3ce9cb8391654b6924868b0393cc33ef653268b
tree1e68ec38bb0c1f9a4a0f620f4319246034fa3218
parent29fbe34a0d41d69c10424a4ea914071fb7b452e7
pcm: direct: Improved suspend/resume support

The current resume handling in PCM direct plugins don't treat multiple
clients properly: once after the slave PCM gets resumed by one
client, the access from others at a later point is seen as already
running although the internal state isn't updated and becomes
inconsistent.  This may end up a negative size, which eventually hangs
up.

This patch is an attempt to improve the handling for resume.  Now the
suspended state is treated similarly like XRUN; namely, we keep the
slave PCM "recoveries" count that is modified at each time the slave
PCM XRUN happens, so that we can check the inconsistency against the
client's state.  As a differentiation to XRUN, we set the highest bit
of recoveries count when the slave stream hits SUSPENDED state.  This
bit is referred at comparing with clients, and the client's state is
updated to either XRUN or SUSPENDED depending on this bit.

Along with this change, the actual resume is done in
snd_pcm_direct_slave_recover(), and snd_pcm_direct_resume() rather
calls this internally.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
src/pcm/pcm_direct.c
src/pcm/pcm_dmix.c
src/pcm/pcm_dshare.c
src/pcm/pcm_dsnoop.c