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
parent e9c40dead8
commit f61eed1a82

View File

@ -219,7 +219,7 @@ AlsaInputStream::PrepareSockets() noexcept
void
AlsaInputStream::DispatchSockets() noexcept
{
try {
non_block.DispatchSockets(*this, capture_handle);
const std::scoped_lock<Mutex> protect(mutex);
@ -238,16 +238,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)