summaryrefslogtreecommitdiff
path: root/configure.ac
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2016-06-30 15:32:40 +0200
committerTakashi Iwai <tiwai@suse.de>2016-07-11 15:25:30 +0200
commit54931e5a5455ac681a32a673d4b360d43f34b6b5 (patch)
treea49dc592f1e3ce16239e4aefa22cdd015cac1fa1 /configure.ac
parent16eb412043fd0979c51a511a084a4058d44207a1 (diff)
downloadalsa-lib-54931e5a5455ac681a32a673d4b360d43f34b6b5.tar.gz
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>
Diffstat (limited to 'configure.ac')
-rw-r--r--configure.ac15
1 files changed, 15 insertions, 0 deletions
diff --git a/configure.ac b/configure.ac
index 9eebd0a8..19298289 100644
--- a/configure.ac
+++ b/configure.ac
@@ -632,6 +632,21 @@ elif test "$max_cards" -gt 256; then
fi
AC_DEFINE_UNQUOTED(SND_MAX_CARDS, $max_cards, [Max number of cards])
+dnl Check for thread-safe API functions
+if test "$HAVE_LIBPTHREAD" = "yes"; then
+AC_MSG_CHECKING(for thread-safe API functions)
+AC_ARG_ENABLE(thread-safety,
+ AS_HELP_STRING([--disable-thread-safety],
+ [disable thread-safe API functions]),
+ threadsafe="$enableval", threadsafe="yes")
+if test "$threadsafe" = "yes"; then
+ AC_MSG_RESULT(yes)
+ AC_DEFINE([THREAD_SAFE_API], "1", [Disable thread-safe API functions])
+else
+ AC_MSG_RESULT(no)
+fi
+fi
+
dnl Make a symlink for inclusion of alsa/xxx.h
if test ! -L "$srcdir"/include/alsa ; then
echo "Making a symlink include/alsa"