output/alsa: fix race condition on early snd_pcm_writei() error

During UnlockActivate() while the mutex is unlocked, the IOThread can
set a new error condition, and will never again wake up the
OutputThread.  This race condition can cause a deadlock in the
OutputThread.
This commit is contained in:
Max Kellermann 2017-02-15 11:23:44 +01:00
parent 6636c69a11
commit 47dffe66aa

View File

@ -1211,6 +1211,12 @@ AlsaOutput::Play(const void *chunk, size_t size)
snd_pcm_writei() */
UnlockActivate();
/* check the error again, because a new one may have
been set while our mutex was unlocked in
UnlockActivate() */
if (error)
std::rethrow_exception(error);
/* wait for the DispatchSockets() to make room in the
ring_buffer */
cond.wait(mutex);