- ms2tv(pad->buffer_time / 4000, &tv);
-// ms2tv(1, &tv);
- tv_add(now, &tv, &pad->next_chunk);
- wn->written += ret * pad->bytes_per_frame;
+ if (ret == -EAGAIN)
+ PARA_DEBUG_LOG("EAGAIN\n");
+ else
+ wn->written += ret * pad->bytes_per_frame;
+ if (ret == frames) /* we wrote everything, try again immediately */
+ pad->next_chunk = *now;
+ else {
+ ms2tv(pad->buffer_time / pad->bytes_per_frame / 1000, &tv);
+ tv_add(now, &tv, &pad->next_chunk);
+ }