]> git.alsa-project.org Git - alsa-lib.git/commit
pcm: Fallback open as the first instance for dmix & co
authorTakashi Iwai <tiwai@suse.de>
Thu, 14 Apr 2016 15:33:03 +0000 (17:33 +0200)
committerTakashi Iwai <tiwai@suse.de>
Thu, 14 Apr 2016 15:39:19 +0000 (17:39 +0200)
commitfdba9e1bad8f769a6137e565471f0227f23a3132
treed0baa64c1f013005904ad41c480e8af0be105178
parente57b521c61f0df14b660ce6ba8c5009a63f5b115
pcm: Fallback open as the first instance for dmix & co

dmix and other PCM plugins tries to open a secondary stream with
O_APPEND flag when the shmem was already attached by another.
However, when another streams have been already closed after the
shmem check, this open may return the error EBADFD, since the kernel
accepts O_APPEND only for the secondary streams.

This patch adds a workaround for such a case.  It just retries opening
the stream as the first instance (i.e. without O_APPEND flag).
This is basically safe behavior (the kernel takes care of races), even
we may do this even unconditionally.  But it's bad from the
performance POV, so we do it only when really needed.

Reported-by: Lars Lindqvist <lars.lindqvist@yandex.ru>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
src/pcm/pcm_dmix.c
src/pcm/pcm_dshare.c
src/pcm/pcm_dsnoop.c