diff options
-rw-r--r-- | lib/libsndio/aucat.c | 21 |
1 files changed, 7 insertions, 14 deletions
diff --git a/lib/libsndio/aucat.c b/lib/libsndio/aucat.c index 2639fde63e0..89988433f68 100644 --- a/lib/libsndio/aucat.c +++ b/lib/libsndio/aucat.c @@ -1,4 +1,4 @@ -/* $OpenBSD: aucat.c,v 1.33 2010/01/15 22:28:23 ratchov Exp $ */ +/* $OpenBSD: aucat.c,v 1.34 2010/01/20 13:17:22 jakemsr Exp $ */ /* * Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org> * @@ -41,7 +41,6 @@ struct aucat_hdl { unsigned rstate, wstate; /* one of above */ unsigned rbpf, wbpf; /* read and write bytes-per-frame */ int maxwrite; /* latency constraint */ - int canwrite; /* got POLLOUT event */ int events; /* events the user requested */ unsigned curvol, reqvol; /* current and requested volume */ unsigned devbufsz; /* server side buffer size (in frames) */ @@ -127,7 +126,6 @@ aucat_wmsg(struct aucat_hdl *hdl) hdl->sio.eof = 1; DPERROR("aucat_wmsg: write"); } - hdl->canwrite = 0; return 0; } hdl->wtodo -= n; @@ -334,7 +332,6 @@ aucat_start(struct sio_hdl *sh) hdl->sio.eof = 1; return 0; } - hdl->canwrite = 0; return 1; } @@ -611,7 +608,6 @@ aucat_write(struct sio_hdl *sh, const void *buf, size_t len) hdl->sio.eof = 1; DPERROR("aucat_write: write"); } - hdl->canwrite = 0; return 0; } hdl->maxwrite -= n; @@ -629,14 +625,12 @@ aucat_pollfd(struct sio_hdl *sh, struct pollfd *pfd, int events) struct aucat_hdl *hdl = (struct aucat_hdl *)sh; hdl->events = events; - if (hdl->canwrite) + if (hdl->maxwrite <= 0) events &= ~POLLOUT; - else - events |= POLLOUT; if (hdl->rstate == STATE_MSG) events |= POLLIN; pfd->fd = hdl->fd; - pfd->events = events; + pfd->events = events; return 1; } @@ -646,8 +640,6 @@ aucat_revents(struct sio_hdl *sh, struct pollfd *pfd) struct aucat_hdl *hdl = (struct aucat_hdl *)sh; int revents = pfd->revents; - if (revents & POLLOUT) - hdl->canwrite = 1; if (revents & POLLIN) { while (hdl->rstate == STATE_MSG) { if (!aucat_runmsg(hdl)) { @@ -656,9 +648,10 @@ aucat_revents(struct sio_hdl *sh, struct pollfd *pfd) } } } - revents &= ~POLLOUT; - if (hdl->canwrite && hdl->maxwrite > 0) - revents |= POLLOUT; + if (revents & POLLOUT) { + if (hdl->maxwrite <= 0) + revents &= ~POLLOUT; + } if (hdl->sio.eof) return POLLHUP; return revents & (hdl->events | POLLHUP); |