- if (*wng->loaded < sizeof(short))
- return 0;
- if (powd->to->remaining) /* Non empty buffer, must still be playing */
- return 0;
- return 1;
-}
-
-static int osx_write_post_select(__a_unused struct sched *s,
- struct writer_node *wn)
-{
- struct private_osx_write_data *powd = wn->private_data;
- struct writer_node_group *wng = wn->wng;
- short *data = (short*)wng->buf;
-
- if (!need_new_buffer(wn))
- return 1;
- fill_buffer(powd->to, data, *wng->loaded / sizeof(short));
- powd->to = powd->to->next;
- wn->written = *wng->loaded;
- if (!powd->play) {
- if (AudioOutputUnitStart(powd->audio_unit))
- return -E_UNIT_START;
- powd->play = 1;
+ while (powd->to->remaining <= 0) {
+ ret = btr_node_status(wn->btrn, wn->min_iqs, BTR_NT_LEAF);
+ if (ret <= 0)
+ break;
+ btr_merge(btrn, 8192);
+ bytes = btr_next_buffer(btrn, &data);
+ //PARA_CRIT_LOG("have: %zu\n", bytes);
+ fill_buffer(powd->to, (short *)data, bytes / sizeof(short));
+ btr_consume(btrn, bytes);
+ if (!powd->play) {
+ ret = -E_UNIT_START;
+ if (AudioOutputUnitStart(powd->audio_unit))
+ break;
+ powd->play = 1;
+ }
+ powd->to = powd->to->next;