X-Git-Url: http://git.tuebingen.mpg.de/?a=blobdiff_plain;ds=sidebyside;f=osx_write.c;h=f8476bfde425cb7f41c16c33e13f70d7d6d1c398;hb=3e3d8e1b48bbd8dbf46adf517c311b5e78dc820f;hp=2c6fd0d2ef3867d5ad5e1e6d37db9e3b0083722c;hpb=b66dfd41e268e64b65d2990bdec3d3a7e119e234;p=paraslash.git diff --git a/osx_write.c b/osx_write.c index 2c6fd0d2..f8476bfd 100644 --- a/osx_write.c +++ b/osx_write.c @@ -217,18 +217,18 @@ e0: return ret; } -__malloc static void *osx_write_parse_config_or_die(const char *options) +__malloc static void *osx_write_parse_config_or_die(int argc, char **argv) { struct osx_write_args_info *conf = para_calloc(sizeof(*conf)); /* exits on errors */ - osx_cmdline_parser_string(options, conf, "osx_write"); + osx_write_cmdline_parser(argc, argv, conf); return conf; } static void osx_free_config(void *conf) { - osx_cmdline_parser_free(conf); + osx_write_cmdline_parser_free(conf); } static void osx_write_close(struct writer_node *wn) @@ -285,15 +285,18 @@ static void osx_write_post_select(__a_unused struct sched *s, struct task *t) struct btr_node *btrn = wn->btrn; int ret; + ret = task_get_notification(t); + if (ret < 0) + goto fail; if (!powd) { ret = btr_node_status(btrn, wn->min_iqs, BTR_NT_LEAF); if (ret == 0) return; if (ret < 0) - goto remove_btrn; + goto fail; ret = core_audio_init(wn); if (ret < 0) - goto remove_btrn; + goto fail; powd = wn->private_data; AudioOutputUnitStart(powd->audio_unit); } @@ -303,17 +306,18 @@ static void osx_write_post_select(__a_unused struct sched *s, struct task *t) if (ret < 0 && need_drain_delay(powd)) ret = 0; mutex_unlock(powd->mutex); - if (ret >= 0) - goto out; - AudioOutputUnitStop(powd->audio_unit); - AudioUnitUninitialize(powd->audio_unit); - CloseComponent(powd->audio_unit); - btr_remove_node(&powd->callback_btrn); -remove_btrn: + return; +fail: + assert(ret < 0); + if (powd && powd->callback_btrn) { + AudioOutputUnitStop(powd->audio_unit); + AudioUnitUninitialize(powd->audio_unit); + CloseComponent(powd->audio_unit); + btr_remove_node(&powd->callback_btrn); + } btr_remove_node(&wn->btrn); PARA_NOTICE_LOG("%s\n", para_strerror(-ret)); -out: t->error = ret; } @@ -326,7 +330,7 @@ void osx_write_init(struct writer *w) { struct osx_write_args_info dummy; - osx_cmdline_parser_init(&dummy); + osx_write_cmdline_parser_init(&dummy); w->close = osx_write_close; w->pre_select = osx_write_pre_select; w->post_select = osx_write_post_select; @@ -336,5 +340,5 @@ void osx_write_init(struct writer *w) .short_help = osx_write_args_info_help, .detailed_help = osx_write_args_info_detailed_help }; - osx_cmdline_parser_free(&dummy); + osx_write_cmdline_parser_free(&dummy); }