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.
This commit is contained in:
Max Kellermann 2018-12-04 18:00:52 +01:00
parent 9c5790ab1d
commit 5cb603983e
2 changed files with 8 additions and 3 deletions

View File

@ -50,7 +50,7 @@ AlsaNonBlockPcm::PrepareSockets(MultiSocketMonitor &m, snd_pcm_t *pcm)
void void
AlsaNonBlockPcm::DispatchSockets(MultiSocketMonitor &m, AlsaNonBlockPcm::DispatchSockets(MultiSocketMonitor &m,
snd_pcm_t *pcm) noexcept snd_pcm_t *pcm)
{ {
int count = snd_pcm_poll_descriptors_count(pcm); int count = snd_pcm_poll_descriptors_count(pcm);
if (count <= 0) if (count <= 0)
@ -69,7 +69,10 @@ AlsaNonBlockPcm::DispatchSockets(MultiSocketMonitor &m,
}); });
unsigned short dummy; 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 std::chrono::steady_clock::duration

View File

@ -45,8 +45,10 @@ public:
/** /**
* Wrapper for snd_pcm_poll_descriptors_revents(), to be * Wrapper for snd_pcm_poll_descriptors_revents(), to be
* called from MultiSocketMonitor::DispatchSockets(). * called from MultiSocketMonitor::DispatchSockets().
*
* Throws on error.
*/ */
void DispatchSockets(MultiSocketMonitor &m, snd_pcm_t *pcm) noexcept; void DispatchSockets(MultiSocketMonitor &m, snd_pcm_t *pcm);
}; };
/** /**