From b829b61f516298a0de3907cd4c30aef189dd8dd4 Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Sun, 20 Aug 2006 15:24:33 +0200 Subject: [PATCH] simplify osx_write_post_select() we either use the full buffer or leave it untouched. So wn->written is always zero or wn->loaded. --- osx_writer.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) 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; -- 2.39.5