output/alsa: clear the `period_buffer` in LockCaughtError()

The method Cancel() assumes that the `period_buffer` must be empty
when `active==false`, but that is not the case when Play() fails.

Of course the assertion in Cancel() is not 100% correct, but I decided
to rather fix this in LockCaughtError() because the `period_buffer`
should only be accessed from within the RTIO thread, and this is the
only code path where `active` can be set to `false` with a non-empty
`period_buffer`.

Fixes #423
This commit is contained in:
Max Kellermann 2018-11-13 20:23:22 +01:00
parent 1a43f5145d
commit 3830748de5
2 changed files with 4 additions and 0 deletions

2
NEWS
View File

@ -1,4 +1,6 @@
ver 0.21.3 (not yet released)
* output
- alsa: fix crash bug
ver 0.21.2 (2018/11/12)
* protocol

View File

@ -306,6 +306,8 @@ private:
}
void LockCaughtError() noexcept {
period_buffer.Clear();
const std::lock_guard<Mutex> lock(mutex);
error = std::current_exception();
active = false;