X-Git-Url: http://git.tuebingen.mpg.de/?a=blobdiff_plain;ds=sidebyside;f=osx_write.c;h=551748a4e1f990b12e120a9c15d4fe1d6b2dc19d;hb=2ef39ae4d1e6b0d95991d2b980621fb152211444;hp=cfd02e7453b1ccac04eb951e5f42009801806b55;hpb=f3b4f3298d2dffdb84a121b7d4aa561975f79be9;p=paraslash.git diff --git a/osx_write.c b/osx_write.c index cfd02e74..551748a4 100644 --- a/osx_write.c +++ b/osx_write.c @@ -187,13 +187,12 @@ static OSStatus osx_callback(void * inClientData, #define ENDIAN_FLAGS 0 #endif -static int osx_write_open(struct writer_node *wn) +static void osx_write_open(struct writer_node *wn) { struct private_osx_write_data *powd = para_calloc(sizeof(*powd)); wn->private_data = powd; init_buffers(wn); - return 0; } static int core_audio_init(struct writer_node *wn) @@ -279,19 +278,13 @@ e0: return ret; } -__malloc static void *osx_write_parse_config(const char *options) +__malloc static void *osx_write_parse_config_or_die(const char *options) { - struct osx_write_args_info *conf - = para_calloc(sizeof(struct osx_write_args_info)); - PARA_INFO_LOG("options: %s\n", options); - int ret = osx_cmdline_parser_string(options, conf, "osx_write"); - if (ret) - goto err_out; - return conf; -err_out: - free(conf); - return NULL; + struct osx_write_args_info *conf = para_calloc(sizeof(*conf)); + /* exits on errors */ + osx_cmdline_parser_string(options, conf, "osx_write"); + return conf; } static void osx_free_config(void *conf) @@ -354,13 +347,15 @@ static void osx_write_pre_select(struct sched *s, struct task *t) struct private_osx_write_data *powd = wn->private_data; struct timeval tmp = {.tv_sec = 1, .tv_usec = 0}, delay = tmp; unsigned long divisor; - size_t numbytes = powd->to->remaining * sizeof(short); + size_t numbytes; int ret = btr_node_status(wn->btrn, wn->min_iqs, BTR_NT_LEAF); - if (ret < 0) - sched_min_delay(s); - if (ret <= 0 || numbytes < wn->min_iqs) + if (ret == 0) return; + if (ret < 0 || !powd->audio_unit) + return sched_min_delay(s); + numbytes = powd->to->remaining * sizeof(short); + assert(numbytes > 0); divisor = powd->sample_rate * wn->min_iqs / numbytes; if (divisor) tv_divide(divisor, &tmp, &delay); @@ -377,7 +372,7 @@ void osx_write_init(struct writer *w) w->close = osx_write_close; w->pre_select = osx_write_pre_select; w->post_select = osx_write_post_select; - w->parse_config = osx_write_parse_config; + w->parse_config_or_die = osx_write_parse_config_or_die; w->free_config = osx_free_config; w->shutdown = NULL; /* nothing to do */ w->help = (struct ggo_help) {