X-Git-Url: http://git.tuebingen.mpg.de/?a=blobdiff_plain;f=osx_write.c;h=f8476bfde425cb7f41c16c33e13f70d7d6d1c398;hb=d02f88dfc3911262174afe6017e04d70e8557a7a;hp=0f9d9605926a81fa5be0c4643ca6565fbe0391c2;hpb=02dd632ab2a6696aff7b6c6d108069704cfe871a;p=paraslash.git diff --git a/osx_write.c b/osx_write.c index 0f9d9605..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,18 +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); - btr_free_node(powd->callback_btrn); -remove_btrn: - btr_remove_node(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; } @@ -327,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; @@ -337,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); }