diff options
author | Max Kellermann <max@musicpd.org> | 2018-12-04 18:00:52 +0100 |
---|---|---|
committer | Max Kellermann <max@musicpd.org> | 2018-12-04 18:00:52 +0100 |
commit | 5cb603983e2e20f1d2f9f638be55e945c90bd6b4 (patch) | |
tree | d23dd27a27cfd02def8e4c0dc51e0174a4dd468c /src/lib | |
parent | 9c5790ab1d9bd597bebae4eed7581a97788fc4a8 (diff) |
alsa/NonBlock: throw on snd_pcm_poll_descriptors_revents() error
This function is sparsely documented and a look at the bluez-alsa
source code shows that implementations make undocumented assumptions
on the `struct pollfd` array parameter which can lead to strange
effects.
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/alsa/NonBlock.cxx | 7 | ||||
-rw-r--r-- | src/lib/alsa/NonBlock.hxx | 4 |
2 files changed, 8 insertions, 3 deletions
diff --git a/src/lib/alsa/NonBlock.cxx b/src/lib/alsa/NonBlock.cxx index 3f4a4adc0..7bc1b225b 100644 --- a/src/lib/alsa/NonBlock.cxx +++ b/src/lib/alsa/NonBlock.cxx @@ -50,7 +50,7 @@ AlsaNonBlockPcm::PrepareSockets(MultiSocketMonitor &m, snd_pcm_t *pcm) void AlsaNonBlockPcm::DispatchSockets(MultiSocketMonitor &m, - snd_pcm_t *pcm) noexcept + snd_pcm_t *pcm) { int count = snd_pcm_poll_descriptors_count(pcm); if (count <= 0) @@ -69,7 +69,10 @@ AlsaNonBlockPcm::DispatchSockets(MultiSocketMonitor &m, }); unsigned short dummy; - snd_pcm_poll_descriptors_revents(pcm, pfds, i - pfds, &dummy); + int err = snd_pcm_poll_descriptors_revents(pcm, pfds, i - pfds, &dummy); + if (err < 0) + throw FormatRuntimeError("snd_pcm_poll_descriptors_revents() failed: %s", + snd_strerror(-err)); } std::chrono::steady_clock::duration diff --git a/src/lib/alsa/NonBlock.hxx b/src/lib/alsa/NonBlock.hxx index 6b9f8f940..0242c0f8a 100644 --- a/src/lib/alsa/NonBlock.hxx +++ b/src/lib/alsa/NonBlock.hxx @@ -45,8 +45,10 @@ public: /** * Wrapper for snd_pcm_poll_descriptors_revents(), to be * called from MultiSocketMonitor::DispatchSockets(). + * + * Throws on error. */ - void DispatchSockets(MultiSocketMonitor &m, snd_pcm_t *pcm) noexcept; + void DispatchSockets(MultiSocketMonitor &m, snd_pcm_t *pcm); }; /** |