pcm: Add LIBASOUND_THREAD_SAFE env variable check

For making the debugging with any deadlocks by the newly introduced
thread-safety feature, add a check with LIBASOUND_THREAD_SAFE
environment variable.  When this variable is set to "0", alsa-lib PCM
forcibly disables the whole thread-safe pthread mutex calls.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
Takashi Iwai 2016-07-07 15:21:14 +02:00
parent 7a8a1d1552
commit c4b690278e
2 changed files with 20 additions and 2 deletions

View file

@ -1087,11 +1087,13 @@ static inline void sw_set_period_event(snd_pcm_sw_params_t *params, int val)
#ifdef THREAD_SAFE_API
static inline void __snd_pcm_lock(snd_pcm_t *pcm)
{
pthread_mutex_lock(&pcm->lock);
if (pcm->thread_safe >= 0)
pthread_mutex_lock(&pcm->lock);
}
static inline void __snd_pcm_unlock(snd_pcm_t *pcm)
{
pthread_mutex_unlock(&pcm->lock);
if (pcm->thread_safe >= 0)
pthread_mutex_unlock(&pcm->lock);
}
static inline void snd_pcm_lock(snd_pcm_t *pcm)
{