From: Andre Noll Date: Sun, 20 Aug 2006 13:24:33 +0000 (+0200) Subject: simplify osx_write_post_select() X-Git-Tag: v0.2.14~49 X-Git-Url: http://git.tue.mpg.de/?a=commitdiff_plain;h=b829b61f516298a0de3907cd4c30aef189dd8dd4;p=paraslash.git simplify osx_write_post_select() we either use the full buffer or leave it untouched. So wn->written is always zero or wn->loaded. --- diff --git a/osx_writer.c b/osx_writer.c index 4b505f0e..9ea7ad45 100644 --- a/osx_writer.c +++ b/osx_writer.c @@ -284,20 +284,30 @@ static void osx_writer_close(struct writer_node *wn) 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;