diff options
author | sfan5 <sfan5@live.de> | 2020-09-20 14:45:45 +0200 |
---|---|---|
committer | sfan5 <sfan5@live.de> | 2020-09-20 18:52:54 +0200 |
commit | c1db4630e61abd4367e07c6a6658601aa2047f66 (patch) | |
tree | 5576d2b6b5fdf0a560f3065c8b18c9901c14cfee | |
parent | 03047a0169495c3323ecbaf1c7ea8029c082dc2e (diff) | |
download | mpv-c1db4630e61abd4367e07c6a6658601aa2047f66.tar.bz2 mpv-c1db4630e61abd4367e07c6a6658601aa2047f66.tar.xz |
audio: move start() calls outside of lock
Pull based AOs might want to call ao_read_data() inside start().
This fixes ao_opensles deadlocking.
-rw-r--r-- | audio/out/buffer.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/audio/out/buffer.c b/audio/out/buffer.c index 07545a1bca..f20d79ab08 100644 --- a/audio/out/buffer.c +++ b/audio/out/buffer.c @@ -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); |