alsa-lib/include
Takashi Iwai 54931e5a54 pcm: Add thread-safety to PCM API
Traditionally, many of ALSA library functions are supposed to be
thread-unsafe, and applications are required to take care of thread
safety by themselves.  However, people never be careful enough, and
almost all applications fail in this regard.

This patch is an attempt to harden the thread safety in exported PCM
functions in a simplistic way: just wrap some of exported functions
with the pthread mutex of each PCM object.  Not all API functions are
wrapped by the mutex since it doesn't make sense.  Instead, the
patchset covers only the functions that may be likely called
concurrently.  The supposedly thread-safe API functions are marked in
the document.

For achieving the feature, two new fields are added snd_pcm_t when the
option is enabled: thread_safe and lock.  The former indicates that
the plugin is thread-safe that doesn't need this workaround and the
latter is the pthread mutex.  Currently only hw plugin have
thread_safe=1.  So, the most of real-time sensitive apps won't be
influenced by this patchset.

Although the patch covers most of PCM ops, a few snd_pcm_fast_ops are
left without the extra mutex locking: namely, the ones that may have
blocking behavior, i.e. resume, drain, readi, writei, readn and
writen.  These are supposed to handle own locking in the callbacks.

Also, if anyone wants to disable this new thread-safe API feature, it
can be still turned off via --disable-thread-safety configure option.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2016-07-11 15:25:30 +02:00
..
sound topology: Fix pcm ID & name parsing 2016-05-09 10:30:40 +02:00
alisp.h Changed Jaroslav Kysela's e-mail from perex@suse.cz to perex@perex.cz 2007-10-15 10:24:55 +02:00
alsa-symbols.h Changed Jaroslav Kysela's e-mail from perex@suse.cz to perex@perex.cz 2007-10-15 10:24:55 +02:00
aserver.h Remove unused hostname resolution in shm plugins and aserver 2015-01-28 16:23:06 +01:00
asoundef.h IEC958 definition for consumer status channel update 2008-08-01 13:17:52 +02:00
asoundlib-head.h Portability fix: look for sys/endian.h as well as endian.h 2014-02-24 11:00:53 +01:00
asoundlib-tail.h Create asoundlib.h dynamically according to configure options 2007-07-10 15:58:41 +02:00
bswap.h Introduce bswap.h for portable definitions of byte swap macros. 2016-03-03 16:18:10 +01:00
conf.h conf: Add thread-safe global tree reference 2016-05-17 15:51:20 +02:00
control.h ctl: add an API to set dimension levels to element information 2016-06-30 08:42:17 +02:00
control_external.h all places: doxygen cleanups 2013-04-08 16:42:24 +02:00
error.h all places: doxygen cleanups 2013-04-08 16:42:24 +02:00
global.h include/global.h - don't define timeval and timespec structures for !glibc 2013-11-08 12:34:44 +01:00
hwdep.h hwdep: add FireWire digi00x/tascam driver support 2015-10-05 23:43:29 +02:00
iatomic.h alsa-lib: heavy pcm atomics cleanup 2014-02-11 13:45:16 +01:00
input.h Changed Jaroslav Kysela's e-mail from perex@suse.cz to perex@perex.cz 2007-10-15 10:24:55 +02:00
list.h Replace list.h with its own version 2015-07-27 12:39:54 +02:00
local.h Define some types if missing 2016-03-03 10:59:52 +01:00
Makefile.am Introduce bswap.h for portable definitions of byte swap macros. 2016-03-03 16:18:10 +01:00
mixer.h all places: doxygen cleanups 2013-04-08 16:42:24 +02:00
mixer_abst.h implemented integer volume <-> dB volume conversion functions for simple mixer 2008-04-21 11:44:20 +02:00
output.h Changed Jaroslav Kysela's e-mail from perex@suse.cz to perex@perex.cz 2007-10-15 10:24:55 +02:00
pcm.h pcm: Fix doxygen for two enums 2015-08-24 22:26:11 +02:00
pcm_external.h Fix documentation of external PCM plugin SDK 2005-05-24 09:42:01 +00:00
pcm_extplug.h Use __inline__ for exported headers 2013-04-25 09:52:33 +02:00
pcm_ioplug.h pcm: Add thread-safety to PCM API 2016-07-11 15:25:30 +02:00
pcm_old.h Move old PCM API to pcm_old.h 2005-04-14 14:01:10 +00:00
pcm_plugin.h Changed Jaroslav Kysela's e-mail from perex@suse.cz to perex@perex.cz 2007-10-15 10:24:55 +02:00
pcm_rate.h Query the supported rate ranges from rate plugins 2009-06-02 16:26:03 +02:00
rawmidi.h Remove assert from header files 2007-10-25 15:36:03 +02:00
search.h Corrections by Kevin Conder <kconder@interaccess.com> 2002-03-12 20:14:33 +00:00
seq.h seq: Provide sequencer sound card number / PID via alsa-lib 2016-03-08 10:57:18 +01:00
seq_event.h all places: doxygen cleanups 2013-04-08 16:42:24 +02:00
seq_midi_event.h Changed Jaroslav Kysela's e-mail from perex@suse.cz to perex@perex.cz 2007-10-15 10:24:55 +02:00
seqmid.h Changed Jaroslav Kysela's e-mail from perex@suse.cz to perex@perex.cz 2007-10-15 10:24:55 +02:00
sys.h Ok, added warning to sys/asoundlib.h with redirection to alsa/asoundlib.h. 2001-09-11 12:18:56 +00:00
timer.h Defined symbols exposing the hrtimer to applications. 2009-11-08 09:21:56 +01:00
topology.h topology: Parse front-end DAI name and ID for the PCM 2016-05-09 10:30:40 +02:00
type_compat.h Add more compatibility defines. 2016-03-03 16:18:54 +01:00
use-case.h ucm: docs: Fix doxygen formatting for UCM main page. 2015-06-29 17:44:00 +02:00