free(powd);
}
+static int need_new_buffer(struct writer_node *wn)
+{
+ struct writer_node_group *wng = wn->wng;
+ struct private_osx_writer_data *powd = wn->private_data;
+
+ 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_writer_data *powd = wn->private_data;
struct writer_node_group *wng = wn->wng;
- short *data = (short*)wng->buf + wn->written;
+ short *data = (short*)wng->buf;
- if (*wng->loaded <= wn->written)
- return 1;
- if (powd->to->remaining) /* Non empty buffer, must still be playing */
+ if (!need_new_buffer(wn))
return 1;
- fill_buffer(powd->to, data, (*wng->loaded - wn->written) / sizeof(short));
+ fill_buffer(powd->to, data, *wng->loaded / sizeof(short));
powd->to = powd->to->next;
- wn->written += (*wng->loaded - wn->written);
+ wn->written = *wng->loaded;
if (!powd->play) {
if (AudioOutputUnitStart(powd->output))
return -1;