Commit 2fb34697 authored by borine's avatar borine Committed by Max Kellermann

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.
parent 94b5b9f3
......@@ -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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment