From: Ben Russell <thematrixeatsyou@gmail.com>
To: alsa-devel@alsa-project.org
Cc: Ben Russell <thematrixeatsyou@gmail.com>
Subject: [alsa-devel] [PATCH 3/3] pcm_local: assert() when using mutexes incorrectly
Date: Sun, 22 Sep 2019 15:28:53 +1200 [thread overview]
Message-ID: <20190922032853.6123-4-thematrixeatsyou@gmail.com> (raw)
In-Reply-To: <20190922032853.6123-1-thematrixeatsyou@gmail.com>
This makes it easier to find pcm mutex handling errors.
Signed-off-by: Ben Russell <thematrixeatsyou@gmail.com>
---
src/pcm/pcm_local.h | 32 ++++++++++++++++++++++++--------
1 file changed, 24 insertions(+), 8 deletions(-)
diff --git a/src/pcm/pcm_local.h b/src/pcm/pcm_local.h
index 649d84f2..c1f881a6 100644
--- a/src/pcm/pcm_local.h
+++ b/src/pcm/pcm_local.h
@@ -1153,23 +1153,39 @@ static inline void sw_set_period_event(snd_pcm_sw_params_t *params, int val)
*/
static inline void __snd_pcm_lock(snd_pcm_t *pcm)
{
- if (pcm->lock_enabled)
- pthread_mutex_lock(&pcm->lock);
+ int lock_err;
+
+ if (pcm->lock_enabled) {
+ lock_err = pthread_mutex_lock(&pcm->lock);
+ assert(lock_err == 0);
+ }
}
static inline void __snd_pcm_unlock(snd_pcm_t *pcm)
{
- if (pcm->lock_enabled)
- pthread_mutex_unlock(&pcm->lock);
+ int unlock_err;
+
+ if (pcm->lock_enabled) {
+ unlock_err = pthread_mutex_unlock(&pcm->lock);
+ assert(unlock_err == 0);
+ }
}
static inline void snd_pcm_lock(snd_pcm_t *pcm)
{
- if (pcm->lock_enabled && pcm->need_lock)
- pthread_mutex_lock(&pcm->lock);
+ int lock_err;
+
+ if (pcm->lock_enabled && pcm->need_lock) {
+ lock_err = pthread_mutex_lock(&pcm->lock);
+ assert(lock_err == 0);
+ }
}
static inline void snd_pcm_unlock(snd_pcm_t *pcm)
{
- if (pcm->lock_enabled && pcm->need_lock)
- pthread_mutex_unlock(&pcm->lock);
+ int unlock_err;
+
+ if (pcm->lock_enabled && pcm->need_lock) {
+ unlock_err = pthread_mutex_unlock(&pcm->lock);
+ assert(unlock_err == 0);
+ }
}
/*
--
2.23.0
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
next prev parent reply other threads:[~2019-09-22 3:33 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-22 3:28 [alsa-devel] [PATCH 0/3] Make pcm_ioplug check lock status before locking (fixes pcm_jack lockups) Ben Russell
2019-09-22 3:28 ` [alsa-devel] [PATCH 1/3] pcm_local: Add snd_pcm_is_locked Ben Russell
2019-09-22 3:28 ` [alsa-devel] [PATCH 2/3] pcm_ioplug: Don't unlock+lock if we're not locked Ben Russell
2019-09-22 3:28 ` Ben Russell [this message]
2019-09-22 20:25 ` [alsa-devel] [PATCH 0/3] Make pcm_ioplug check lock status before locking (fixes pcm_jack lockups) Takashi Iwai
2019-09-24 7:45 ` Ben Russell
2019-09-24 10:18 ` Takashi Iwai
2019-09-25 6:10 ` Ben Russell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190922032853.6123-4-thematrixeatsyou@gmail.com \
--to=thematrixeatsyou@gmail.com \
--cc=alsa-devel@alsa-project.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox