mirror of https://github.com/ericonr/sndio.git
add aucat_setfl() to set nbio flag
This commit is contained in:
parent
7fa1603c83
commit
2bfcdf435b
|
@ -323,6 +323,17 @@ aucat_close(struct aucat *hdl, int eof)
|
|||
; /* nothing */
|
||||
}
|
||||
|
||||
int
|
||||
aucat_setfl(struct aucat *hdl, int nbio, int *eof)
|
||||
{
|
||||
if (fcntl(hdl->fd, F_SETFL, nbio ? O_NONBLOCK : 0) < 0) {
|
||||
DPERROR("aucat_setfl: fcntl");
|
||||
*eof = 1;
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int
|
||||
aucat_pollfd(struct aucat *hdl, struct pollfd *pfd, int events)
|
||||
{
|
||||
|
|
|
@ -24,5 +24,6 @@ int aucat_open(struct aucat *, const char *, char *, unsigned, int);
|
|||
void aucat_close(struct aucat *, int);
|
||||
int aucat_pollfd(struct aucat *, struct pollfd *, int);
|
||||
int aucat_revents(struct aucat *, struct pollfd *);
|
||||
int aucat_setfl(struct aucat *, int, int *);
|
||||
|
||||
#endif /* !defined(AUCAT_H) */
|
||||
|
|
|
@ -42,7 +42,7 @@ struct sio_aucat_hdl {
|
|||
unsigned curvol, reqvol; /* current and requested volume */
|
||||
int delta; /* some of received deltas */
|
||||
#define PSTATE_INIT 0
|
||||
#define RSTATE_UN 1
|
||||
#define PSTATE_RUN 1
|
||||
int pstate;
|
||||
};
|
||||
|
||||
|
@ -194,12 +194,9 @@ sio_aucat_start(struct sio_hdl *sh)
|
|||
return 0;
|
||||
hdl->aucat.rstate = RSTATE_MSG;
|
||||
hdl->aucat.rtodo = sizeof(struct amsg);
|
||||
if (fcntl(hdl->aucat.fd, F_SETFL, O_NONBLOCK) < 0) {
|
||||
DPERROR("sio_aucat_start: fcntl(0)");
|
||||
hdl->sio.eof = 1;
|
||||
if (!aucat_setfl(&hdl->aucat, 1, &hdl->sio.eof))
|
||||
return 0;
|
||||
}
|
||||
hdl->pstate = RSTATE_UN;
|
||||
hdl->pstate = PSTATE_RUN;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -211,12 +208,8 @@ sio_aucat_stop(struct sio_hdl *sh)
|
|||
struct sio_aucat_hdl *hdl = (struct sio_aucat_hdl *)sh;
|
||||
unsigned n, count;
|
||||
|
||||
if (fcntl(hdl->aucat.fd, F_SETFL, 0) < 0) {
|
||||
DPERROR("sio_aucat_stop: fcntl(0)");
|
||||
hdl->sio.eof = 1;
|
||||
if (!aucat_setfl(&hdl->aucat, 0, &hdl->sio.eof))
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* complete message or data block in progress
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue