struct timeval restart_barrier;
/** Last time we received status data from para_server. */
struct timeval last_status_read;
+ size_t min_iqs;
/** The offset value announced by para_server. */
int offset_seconds;
/** The length of the current audio file as announced by para_server. */
}
if (st->ct->status != CL_RECEIVING)
goto out;
- ret = btr_node_status(st->btrn, 0, BTR_NT_LEAF);
- if (ret <= 0)
+ ret = btr_node_status(st->btrn, st->min_iqs, BTR_NT_LEAF);
+ if (ret <= 0) {
+ struct timeval diff;
+ tv_diff(now, &st->last_status_read, &diff);
+ if (diff.tv_sec > 61)
+ kill_btrn(st->ct->btrn, &st->ct->task,
+ -E_STATUS_TIMEOUT);
goto out;
+ }
+ btr_merge(st->btrn, st->min_iqs);
sz = btr_next_buffer(st->btrn, &buf);
ret = for_each_stat_item(buf, sz, update_item);
if (ret < 0) {
kill_btrn(st->ct->btrn, &st->ct->task, ret);
goto out;
}
- if (sz != ret)
+ if (sz != ret) {
+ btr_consume(st->btrn, sz - ret);
st->last_status_read = *now;
- else {
- struct timeval diff;
- tv_diff(now, &st->last_status_read, &diff);
- if (diff.tv_sec > 61)
- kill_btrn(st->ct->btrn, &st->ct->task,
- -E_STATUS_TIMEOUT);
- }
- btr_consume(st->btrn, sz - ret);
+ st->min_iqs = 0;
+ } else /* current status item crosses buffers */
+ st->min_iqs = sz + 1;
goto out;
}
if (tv_diff(now, &st->restart_barrier, NULL) < 0)