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.
This commit is contained in:
Kevin Mitchell 2020-06-17 01:55:18 -07:00
parent b16d8865b7
commit 5e323333cf
No known key found for this signature in database
GPG Key ID: 559A34B46A917232
1 changed files with 7 additions and 2 deletions

View File

@ -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;
}