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:
parent
94b5b9f370
commit
2fb34697c7
|
@ -234,7 +234,7 @@ AlsaInputStream::PrepareSockets() noexcept
|
||||||
|
|
||||||
void
|
void
|
||||||
AlsaInputStream::DispatchSockets() noexcept
|
AlsaInputStream::DispatchSockets() noexcept
|
||||||
{
|
try {
|
||||||
non_block.DispatchSockets(*this, capture_handle);
|
non_block.DispatchSockets(*this, capture_handle);
|
||||||
|
|
||||||
const std::scoped_lock<Mutex> protect(mutex);
|
const std::scoped_lock<Mutex> protect(mutex);
|
||||||
|
@ -253,16 +253,17 @@ AlsaInputStream::DispatchSockets() noexcept
|
||||||
if (n_frames == -EAGAIN)
|
if (n_frames == -EAGAIN)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (Recover(n_frames) < 0) {
|
if (Recover(n_frames) < 0)
|
||||||
postponed_exception = std::make_exception_ptr(std::runtime_error("PCM error - stream aborted"));
|
throw std::runtime_error("PCM error - stream aborted");
|
||||||
InvokeOnAvailable();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t nbytes = n_frames * frame_size;
|
size_t nbytes = n_frames * frame_size;
|
||||||
CommitWriteBuffer(nbytes);
|
CommitWriteBuffer(nbytes);
|
||||||
}
|
}
|
||||||
|
catch (...) {
|
||||||
|
postponed_exception = std::current_exception();
|
||||||
|
InvokeOnAvailable();
|
||||||
|
}
|
||||||
|
|
||||||
inline int
|
inline int
|
||||||
AlsaInputStream::Recover(int err)
|
AlsaInputStream::Recover(int err)
|
||||||
|
|
Loading…
Reference in New Issue