summaryrefslogtreecommitdiff
path: root/libasound.c
diff options
context:
space:
mode:
Diffstat (limited to 'libasound.c')
-rw-r--r--libasound.c41
1 files changed, 19 insertions, 22 deletions
diff --git a/libasound.c b/libasound.c
index 749a879..92398cf 100644
--- a/libasound.c
+++ b/libasound.c
@@ -327,32 +327,29 @@ snd_pcm_readi(snd_pcm_t *pcm, void *buffer, snd_pcm_uframes_t size)
snd_pcm_sframes_t
snd_pcm_avail_update(snd_pcm_t *pcm)
{
- while (1) {
- struct pollfd pfd[16];
- int nfds = sio_nfds(pcm->hdl);
- assert((unsigned int)nfds < ARRAY_SIZE(pfd));
-
- // FIXME: should POLLIN / POLLOUT depending on stream
- if (!sio_pollfd(pcm->hdl, pfd, POLLOUT)) {
- WARNX1("sio_pollfd failed");
- goto fail;
- }
-
- errno = 0;
- while ((nfds = poll(pfd, nfds, -1)) < 0) {
- if (errno == EINVAL) {
- WARNX1("poll EINVAL");
- goto fail;
- }
- }
+ struct pollfd pfd[16];
+ int nfds = sio_nfds(pcm->hdl);
+ assert((unsigned int)nfds < ARRAY_SIZE(pfd));
- const int events = sio_revents(pcm->hdl, pfd);
- if (!(events & (POLLOUT | POLLIN)))
- continue;
+ // FIXME: should POLLIN / POLLOUT depending on stream
+ if (!sio_pollfd(pcm->hdl, pfd, POLLOUT)) {
+ WARNX1("sio_pollfd failed");
+ goto fail;
+ }
- break;
+ // FIXME: timeout should be period time
+ errno = 0;
+ while ((nfds = poll(pfd, nfds, -1)) < 0) {
+ if (errno == EINVAL) {
+ WARNX1("poll EINVAL");
+ goto fail;
+ }
}
+ const int events = sio_revents(pcm->hdl, pfd);
+ if (!(events & (POLLOUT | POLLIN)))
+ goto fail;
+
return pcm->hw.par.appbufsz;
fail: