if(dev->read_subdev && dev->read_subdev->async){
s = dev->read_subdev;
async = s->async;
- if(!s->busy ||
- (async->buf_read_count < async->buf_write_count) ||
- !(s->subdev_flags&SDF_RUNNING)){
+ if(!s->busy
+ || comedi_buf_read_n_available(async)>0
+ || !(s->subdev_flags&SDF_RUNNING)){
mask |= POLLIN | POLLRDNORM;
}
}
if(dev->write_subdev && dev->write_subdev->async){
s = dev->write_subdev;
async = s->async;
- if(!s->busy ||
- !(s->subdev_flags&SDF_RUNNING) ||
- (async->buf_write_count < async->buf_read_count +
- async->prealloc_bufsz)){
+ if(!s->busy
+ || !(s->subdev_flags&SDF_RUNNING)
+ || comedi_buf_write_n_available(async)>0){
mask |= POLLOUT | POLLWRNORM;
}
}
return 0;
}
+unsigned int comedi_buf_write_n_available(comedi_async *async)
+{
+ unsigned int free_end = async->buf_read_count + async->prealloc_bufsz;
+
+ return free_end - async->buf_free_count;
+}
unsigned int comedi_buf_write_alloc(comedi_async *async, unsigned int nbytes)
{
#endif
int comedi_buf_get(comedi_async *async, sampl_t *x);
+unsigned int comedi_buf_write_n_available(comedi_async *async);
unsigned int comedi_buf_write_alloc(comedi_async *async, unsigned int nbytes);
unsigned int comedi_buf_write_alloc_strict(comedi_async *async, unsigned int nbytes);
void comedi_buf_write_free(comedi_async *async, unsigned int nbytes);