alsa-lib/src
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
..
alisp autotools: update style 2014-02-26 08:16:22 +01:00
conf conf/ucm: chtrt5645: Add UCM config for chtrt5645 2016-07-08 15:05:48 +02:00
control hctl: remove assertion from element event handler because removal event overwrites all of queued events 2016-07-11 12:44:38 +02:00
hwdep conf: Add thread-safe global tree reference 2016-05-17 15:51:20 +02:00
mixer mixer: Fix unused parameter warnings 2014-11-21 15:22:01 +01:00
pcm pcm: Add thread-safety to PCM API 2016-07-11 15:25:30 +02:00
rawmidi conf: Add thread-safe global tree reference 2016-05-17 15:51:20 +02:00
seq conf: Add thread-safe global tree reference 2016-05-17 15:51:20 +02:00
timer conf: Add thread-safe global tree reference 2016-05-17 15:51:20 +02:00
topology topology: initialize variable for error output 2016-07-11 15:24:12 +02:00
ucm ucm: add cset-tlv 2016-04-13 15:40:17 +02:00
async.c async: Handle previously installed signal handler 2016-06-01 08:16:31 +02:00
conf.c conf: Add thread-safe global tree reference 2016-05-17 15:51:20 +02:00
confmisc.c Replace unsafe characters with _ in card name 2015-06-29 20:33:26 +02:00
dlmisc.c dlmisc: Remove unused label 2014-11-16 09:43:39 +01:00
error.c all places: doxygen cleanups 2013-04-08 16:42:24 +02:00
input.c Make all the remaining ops structure constants. 2008-11-21 20:48:33 +01:00
Makefile.am topology: autotools: Add build support for topology core 2015-07-30 17:10:14 +02:00
names.c Remove docs for snd_names_list and snd_names_list_free 2012-01-19 12:35:20 +01:00
output.c fix doc errors 2009-08-04 09:17:20 +02:00
shmarea.c support building w/out System V shared memory 2015-11-05 14:37:11 +01:00
socket.c Remove unused hostname resolution in shm plugins and aserver 2015-01-28 16:23:06 +01:00
userfile.c snd_user_file: fix memory leak 2014-11-03 17:26:00 +01:00
Versions.in Fix wrong exported functions 2008-02-04 14:15:44 +01:00