input/plugins/Alsa: catch all exceptions

snd_pcm_poll_descriptors_revents() may return any error code; the
ALSA docs do not constrain the permitted values. A 'hw' device
will only ever return an error if the pfd array passed in is
invalid (-EINVAL), but other I/O plugins may return arbitary
errors. For example a network-based device may return -EPIPE etc.
The resulting exception thrown by
AlsaNonBlockPcm::DispatchSockets() must be caught to prevent the
mpd process from being aborted.
This commit is contained in:
borine 2023-05-12 10:17:45 +01:00 committed by Max Kellermann
parent 94b5b9f370
commit 2fb34697c7
1 changed files with 7 additions and 6 deletions

View File

@ -234,7 +234,7 @@ AlsaInputStream::PrepareSockets() noexcept
void
AlsaInputStream::DispatchSockets() noexcept
{
try {
non_block.DispatchSockets(*this, capture_handle);
const std::scoped_lock<Mutex> protect(mutex);
@ -253,16 +253,17 @@ AlsaInputStream::DispatchSockets() noexcept
if (n_frames == -EAGAIN)
return;
if (Recover(n_frames) < 0) {
postponed_exception = std::make_exception_ptr(std::runtime_error("PCM error - stream aborted"));
InvokeOnAvailable();
return;
}
if (Recover(n_frames) < 0)
throw std::runtime_error("PCM error - stream aborted");
}
size_t nbytes = n_frames * frame_size;
CommitWriteBuffer(nbytes);
}
catch (...) {
postponed_exception = std::current_exception();
InvokeOnAvailable();
}
inline int
AlsaInputStream::Recover(int err)