diff options
author | Kevin Mitchell <kevmitch@gmail.com> | 2020-06-17 01:55:18 -0700 |
---|---|---|
committer | Kevin Mitchell <kevmitch@gmail.com> | 2020-06-17 02:22:51 -0700 |
commit | 5e323333cf128bc159c3bac9e412ff8c6de41693 (patch) | |
tree | 51c7a0fafb3b35c17fc3e5d1bcb981f3cc9e48c2 /audio/out | |
parent | b16d8865b70b4459f87c519159b5e400a9ae7e00 (diff) | |
download | mpv-5e323333cf128bc159c3bac9e412ff8c6de41693.tar.bz2 mpv-5e323333cf128bc159c3bac9e412ff8c6de41693.tar.xz |
audio: don't lock ao_control for pull mode drivers
The pull mode APIs were previously required to have thread-safe
ao_controls. However, locks were added in b83bdd1 for parity with push
mode. This introduced deadlocks in ao_wasapi.
Instead, only lock ao_control for the push mode APIs.
fixes #7787
See also #7832, #7811. We'll wait for feedback to see if those should
also be closed.
Diffstat (limited to 'audio/out')
-rw-r--r-- | audio/out/buffer.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/audio/out/buffer.c b/audio/out/buffer.c index dc053c3e2c..2992180854 100644 --- a/audio/out/buffer.c +++ b/audio/out/buffer.c @@ -288,9 +288,14 @@ int ao_control(struct ao *ao, enum aocontrol cmd, void *arg) struct buffer_state *p = ao->buffer_state; int r = CONTROL_UNKNOWN; if (ao->driver->control) { - pthread_mutex_lock(&p->lock); + // Only need to lock in push mode. + if (ao->driver->write) + pthread_mutex_lock(&p->lock); + r = ao->driver->control(ao, cmd, arg); - pthread_mutex_unlock(&p->lock); + + if (ao->driver->write) + pthread_mutex_unlock(&p->lock); } return r; } |