struct private_alsa_write_data *pad = wn->private_data;
struct timeval tv;
snd_pcm_sframes_t avail, underrun;
- int ret;
+ int ret = btr_node_status(wn->btrn, wn->min_iqs, BTR_NT_LEAF);
- if (!pad->handle)
- return;
- ret = btr_node_status(wn->btrn, wn->min_iqs, BTR_NT_LEAF);
- if (ret < 0)
- sched_request_timeout_ms(20, s);
- if (ret <= 0)
+ if (ret == 0)
return;
+ if (ret < 0 || !pad->handle)
+ return sched_min_delay(s);
/*
* Data is available to be written to the alsa handle. Compute number
* of milliseconds until next buffer underrun would occur.
{
struct writer_node *wn = container_of(t, struct writer_node, task);
struct private_file_write_data *pfwd = wn->private_data;
- int ret;
+ int ret = btr_node_status(wn->btrn, wn->min_iqs, BTR_NT_LEAF);
- t->error = 0;
- ret = btr_node_status(wn->btrn, wn->min_iqs, BTR_NT_LEAF);
- if (ret > 0 && pfwd->fd >= 0)
- para_fd_set(pfwd->fd, &s->wfds, &s->max_fileno);
- else if (ret != 0) /* error or bos and fd not yet open */
- sched_min_delay(s);
+ if (ret == 0)
+ return;
+ if (ret < 0 || pfwd->fd < 0)
+ return sched_min_delay(s);
+ para_fd_set(pfwd->fd, &s->wfds, &s->max_fileno);
}
static void file_write_close(struct writer_node *wn)
struct private_oss_write_data *powd = wn->private_data;
int ret = btr_node_status(wn->btrn, wn->min_iqs, BTR_NT_LEAF);
- t->error = 0;
- if (ret < 0)
- sched_min_delay(s);
- else if (ret > 0)
- para_fd_set(powd->fd, &s->wfds, &s->max_fileno);
+ if (ret == 0)
+ return;
+ if (ret < 0 || powd->fd < 0)
+ return sched_min_delay(s);
+ para_fd_set(powd->fd, &s->wfds, &s->max_fileno);
}
static void oss_close(struct writer_node *wn)
struct private_osx_write_data *powd = wn->private_data;
struct timeval tmp = {.tv_sec = 1, .tv_usec = 0}, delay = tmp;
unsigned long divisor;
- size_t numbytes = powd->to->remaining * sizeof(short);
+ size_t numbytes;
int ret = btr_node_status(wn->btrn, wn->min_iqs, BTR_NT_LEAF);
- if (ret < 0)
- sched_min_delay(s);
- if (ret <= 0 || numbytes < wn->min_iqs)
+ if (ret == 0)
return;
+ if (ret < 0 || !powd->audio_unit)
+ return sched_min_delay(s);
+ numbytes = powd->to->remaining * sizeof(short);
+ assert(numbytes > 0);
divisor = powd->sample_rate * wn->min_iqs / numbytes;
if (divisor)
tv_divide(divisor, &tmp, &delay);