]> git.alsa-project.org Git - alsa-lib.git/commit
pcm: Add the PCM state checks to plugins
authorTakashi Iwai <tiwai@suse.de>
Tue, 29 Nov 2016 13:31:20 +0000 (14:31 +0100)
committerTakashi Iwai <tiwai@suse.de>
Tue, 29 Nov 2016 15:22:20 +0000 (16:22 +0100)
commitea74ebbe4db81aeaedcff11bc5eb6ce139db1118
treef7064dc774af828edd65c73c7c0e46313e2476bd
parent3e4887c1121a7b126a4948740a8e6b76218c1c19
pcm: Add the PCM state checks to plugins

I noticed that some plugin codes have no proper PCM state checks and
it results in expected outcomes.  For example, when snd_pcm_drain() is
called for a dmix PCM after calling snd_pcm_drop(), it stalls
unexpectedly.  It's just because its drain callback doesn't expect the
SND_PCM_SETUP state.

We can fix such a bug in each place one by one, but a safer way would
be to filter out all such cases commonly in the PCM API functions
themselves.  This patch adds the PCM state sanity checks to major API
functions so that they return -EBADFD when called in the unexpected
PCM states.

As well as for the thread-safety extension, it'd be a question of the
performance; again at this time, the hw PCM is considered as an
exception, and it has pcm->own_state_check flag set, which means that
the common PCM state checks are skipped.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
src/pcm/pcm.c
src/pcm/pcm_hw.c
src/pcm/pcm_local.h