X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=fade.c;h=c1d15d723b66aa252f10a349e27b4b52d5cd9552;hp=2954fa32689887e9b8703f0eb34c29e710e6c072;hb=7ebb3ef8d2280c19e741b97627bfcf894c7e3117;hpb=3764561bd59cac22aa4c8f5ea811eebc140af51b diff --git a/fade.c b/fade.c index 2954fa32..c1d15d72 100644 --- a/fade.c +++ b/fade.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1998-2012 Andre Noll + * Copyright (C) 1998-2014 Andre Noll * * Licensed under the GPL v2. For licencing details see COPYING. */ @@ -14,6 +14,7 @@ #include "string.h" #include "mix.h" #include "error.h" +#include "ggo.h" #include "version.h" INIT_FADE_ERRLISTS; @@ -26,7 +27,7 @@ static struct mixer supported_mixer[] = {MIXER_ARRAY}; #define FOR_EACH_MIXER(i) for ((i) = 0; (i) < NUM_SUPPORTED_MIXERS; (i)++) static int loglevel; -__printf_2_3 void date_log(int ll, const char *fmt, ...) +static __printf_2_3 void date_log(int ll, const char *fmt, ...) { va_list argp; time_t t1; @@ -52,7 +53,7 @@ static int fade(struct mixer *m, struct mixer_handle *h, int new_vol, int fade_t unsigned long long tmp, tmp2; /* Careful with that axe, Eugene! */ if (fade_time <= 0) - return 1; + return m->set(h, new_vol); secs = fade_time; PARA_NOTICE_LOG("fading to %d in %d seconds\n", new_vol, secs); ret = m->get(h); @@ -89,7 +90,7 @@ static void client_cmd(const char *cmd) pid_t pid; char *cmdline = make_message(BINDIR "/para_client %s", cmd); - PARA_INFO_LOG("%s\n", cmdline); + PARA_NOTICE_LOG("%s\n", cmdline); ret = para_exec_cmdline_pid(&pid, cmdline, fds); free(cmdline); if (ret < 0) { @@ -286,15 +287,26 @@ static struct mixer *get_mixer_or_die(void) exit(EXIT_FAILURE); } +__noreturn static void print_help_and_die(void) +{ + struct ggo_help h = DEFINE_GGO_HELP(fade); + bool d = conf.detailed_help_given; + + ggo_print_help(&h, d? GPH_STANDARD_FLAGS_DETAILED : GPH_STANDARD_FLAGS); + exit(0); +} + int main(int argc, char *argv[]) { int ret; struct mixer *m; struct mixer_handle *h = NULL; - if (fade_cmdline_parser(argc, argv, &conf)) - exit(EXIT_FAILURE); - HANDLE_VERSION_FLAG("fade", conf); + fade_cmdline_parser(argc, argv, &conf); + loglevel = get_loglevel_by_name(conf.loglevel_arg); + version_handle_flag("fade", conf.version_given); + if (conf.help_given || conf.detailed_help_given) + print_help_and_die(); ret = configfile_exists(); if (!ret && conf.config_file_given) { PARA_EMERG_LOG("can not read config file %s\n", @@ -311,8 +323,8 @@ int main(int argc, char *argv[]) }; fade_cmdline_parser_config_file(conf.config_file_arg, &conf, ¶ms); + loglevel = get_loglevel_by_name(conf.loglevel_arg); } - loglevel = get_loglevel_by_name(conf.loglevel_arg); init_mixers(); m = get_mixer_or_die(); ret = m->open(conf.mixer_device_arg, &h);