audio: move start() calls outside of lock

Pull based AOs might want to call ao_read_data() inside start().
This fixes ao_opensles deadlocking.
This commit is contained in:
sfan5 2020-09-20 14:45:45 +02:00
parent 03047a0169
commit c1db4630e6
1 changed files with 10 additions and 3 deletions

View File

@ -327,6 +327,7 @@ void ao_reset(struct ao *ao)
void ao_start(struct ao *ao)
{
struct buffer_state *p = ao->buffer_state;
bool do_start = false;
pthread_mutex_lock(&p->lock);
@ -334,11 +335,15 @@ void ao_start(struct ao *ao)
if (!ao->driver->write && !p->streaming) {
p->streaming = true;
ao->driver->start(ao);
do_start = true;
}
pthread_mutex_unlock(&p->lock);
// Pull AOs might call ao_read_data() so do this outside the lock.
if (do_start)
ao->driver->start(ao);
ao_wakeup_playthread(ao);
}
@ -346,7 +351,7 @@ void ao_set_paused(struct ao *ao, bool paused)
{
struct buffer_state *p = ao->buffer_state;
bool wakeup = false;
bool do_reset = false;
bool do_reset = false, do_start = false;
pthread_mutex_lock(&p->lock);
@ -376,7 +381,7 @@ void ao_set_paused(struct ao *ao, bool paused)
p->hw_paused = false;
} else {
if (!p->streaming)
ao->driver->start(ao);
do_start = true;
p->streaming = true;
}
wakeup = true;
@ -387,6 +392,8 @@ void ao_set_paused(struct ao *ao, bool paused)
if (do_reset)
ao->driver->reset(ao);
if (do_start)
ao->driver->start(ao);
if (wakeup)
ao_wakeup_playthread(ao);