From: Andre Noll Date: Mon, 1 Jul 2013 19:06:48 +0000 (+0200) Subject: Merge branch 't/versioning_improvements' X-Git-Tag: v0.4.13~23 X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=commitdiff_plain;h=e2eebf654cae2fc004cee516a0e165127c0214ca;hp=-c Merge branch 't/versioning_improvements' Cooking for ~2 weeks. 15e99a version.c: Mark version_git() as const. 9bdebf Remove CODENAME macro. be2f6b gui: Use version_single_line(). d60dae Improve man page layout. 5dbc9a afh/play: Include supported audio formats in help output. 042767 Use self-made help to avoid recompilations on version changes. 48f1fc Provide "purpose" texts. aa74a9 Revamp ggo help. 9f7a49 afh_recv: Replace ggo text section by description. b59e0e Make gengetopt descriptions work. 06b3e7 Introduce version.c to limit recompilation on version changes. 75feac Make all commands print git version and improve version string. b01605 Avoid unwanted log messages during startup. 625fdb Don't check return value of command line parsers unnecessarily. 533b03 Build receivers, filters and writers without -h and -V support. b59a3c filter: Wrap lines in the available filter list. 9e56d3 audioc: Print config file errors. e5264d doc: Rewrite udp sender description 5ec373 client: Fix typo in comment. 6d5159 client: Remove duplicate include. --- e2eebf654cae2fc004cee516a0e165127c0214ca diff --combined Makefile.in index 698599e5,e5d87abe..f82afd7b --- a/Makefile.in +++ b/Makefile.in @@@ -9,6 -9,7 +9,7 @@@ PACKAGE_VERSION := @PACKAGE_VERSION PACKAGE_STRING := @PACKAGE_STRING@ install_sh := @install_sh@ executables := @executables@ + ggo_descriptions_declared := @ggo_descriptions_declared@ GENGETOPT := @gengetopt@ HELP2MAN := @help2man@ @@@ -18,7 -19,6 +19,6 @@@ build_date := $(shell date uname_s := $(shell uname -s 2>/dev/null || echo "UNKNOWN_OS") uname_rs := $(shell uname -rs) cc_version := $(shell $(CC) --version | head -n 1) - codename := spectral gravity GIT_VERSION := $(shell ./GIT-VERSION-GEN git-version.h) @@@ -67,7 -67,6 +67,6 @@@ CPPFLAGS += -Wchar-subscript CPPFLAGS += -DBINDIR='"$(BINDIR)"' CPPFLAGS += -DBUILD_DATE='"$(build_date)"' CPPFLAGS += -DUNAME_RS='"$(uname_rs)"' - CPPFLAGS += -DCODENAME='"$(codename)"' CPPFLAGS += -DCC_VERSION='"$(cc_version)"' CPPFLAGS += -Werror-implicit-function-declaration CPPFLAGS += -Wmissing-noreturn @@@ -182,10 -181,6 +181,10 @@@ $(object_dir)/mp3dec_filter.o: mp3dec_f @[ -z "$(Q)" ] || echo 'CC $<' $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) @mad_cppflags@ $< +$(object_dir)/compress_filter.o: compress_filter.c | $(object_dir) + @[ -z "$(Q)" ] || echo 'CC $<' + $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) -O3 $< + $(object_dir)/aacdec_filter.o: aacdec_filter.c | $(object_dir) @[ -z "$(Q)" ] || echo 'CC $<' $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) @faad_cppflags@ $< diff --combined NEWS index 8a400d6f,07481964..866904e3 --- a/NEWS +++ b/NEWS @@@ -8,9 -8,7 +8,13 @@@ by clock_gettime() on systems which support it. - Speed and usability improvements for para_gui. - para_client now restores the fd flags of stdin and stdout - on shutdown + on shutdown. ++ - Improved manual pages. ++ - Consistent version strings for all executables. ++ - Reduced depencies on generated files result in fewer ++ recompilations on changes. + - Performance improvements for the compress filter. + - Improved downloads web page. ----------------------------------------- 0.4.12 (2012-12-20) "volatile relativity" diff --combined audioc.c index be67ebda,164a1554..0edab366 --- a/audioc.c +++ b/audioc.c @@@ -17,6 -17,7 +17,7 @@@ #include "net.h" #include "string.h" #include "fd.h" + #include "ggo.h" #include "version.h" INIT_AUDIOC_ERRLISTS; @@@ -42,25 -43,6 +43,25 @@@ static char *concat_args(unsigned argc return buf; } +static int connect_audiod(const char *sname, char *args) +{ + int fd = -1, ret; + + ret = connect_local_socket(sname); + if (ret < 0) + goto fail; + fd = ret; + ret = send_cred_buffer(fd, args); + if (ret < 0) + goto fail; + return fd; +fail: + PARA_ERROR_LOG("could not connect %s\n", sname); + if (fd >= 0) + close(fd); + return ret; +} + #ifdef HAVE_READLINE #include "list.h" #include "sched.h" @@@ -165,6 -147,8 +166,6 @@@ static int audioc_i9e_line_handler(cha { char *args = NULL; int ret; - if (!line || !*line) - return 0; PARA_DEBUG_LOG("line: %s\n", line); ret = create_argv(line, " ", &conf.inputs); @@@ -173,14 -157,15 +174,14 @@@ conf.inputs_num = ret; args = concat_args(conf.inputs_num, conf.inputs); free_argv(conf.inputs); + if (!args) + return 0; conf.inputs_num = 0; /* required for audioc_cmdline_parser_free() */ - ret = connect_local_socket(socket_name); + ret = connect_audiod(socket_name, args); if (ret < 0) goto out; at->fd = ret; ret = mark_fd_nonblocking(at->fd); - if (ret < 0) - goto close; - ret = send_cred_buffer(at->fd, args); if (ret < 0) goto close; free(args); @@@ -210,7 -195,7 +211,7 @@@ __noreturn static void interactive_sess .loglevel = loglevel, .completers = audiod_completers, }; - PARA_NOTICE_LOG("\n%s\n", VERSION_TEXT("audioc")); + PARA_NOTICE_LOG("\n%s\n", version_text("audioc")); if (conf.history_file_given) history_file = para_strdup(conf.history_file_arg); else { @@@ -279,6 -264,15 +280,15 @@@ static char *configfile_exists(void return NULL; } + __noreturn static void print_help_and_die(void) + { + struct ggo_help h = DEFINE_GGO_HELP(audioc); + bool d = conf.detailed_help_given; + + ggo_print_help(&h, d? GPH_STANDARD_FLAGS_DETAILED : GPH_STANDARD_FLAGS); + exit(0); + } + /** * The client program to connect to para_audiod. * @@@ -297,29 -291,29 +307,29 @@@ */ int main(int argc, char *argv[]) { - int ret = -E_AUDIOC_SYNTAX, fd; + int ret, fd; char *cf, *buf = NULL, *args = NULL; size_t bufsize; - if (audioc_cmdline_parser(argc, argv, &conf)) - goto out; - HANDLE_VERSION_FLAG("audioc", conf); + audioc_cmdline_parser(argc, argv, &conf); + loglevel = get_loglevel_by_name(conf.loglevel_arg); + version_handle_flag("audioc", conf.version_given); + if (conf.help_given || conf.detailed_help_given) + print_help_and_die(); cf = configfile_exists(); if (cf) { struct audioc_cmdline_parser_params params = { .override = 0, .initialize = 0, .check_required = 0, - .check_ambiguity = 0 + .check_ambiguity = 0, + .print_errors = 1, + }; - ret = audioc_cmdline_parser_config_file(cf, &conf, ¶ms); + audioc_cmdline_parser_config_file(cf, &conf, ¶ms); free(cf); - if (ret) { - fprintf(stderr, "parse error in config file\n"); - exit(EXIT_FAILURE); - } + loglevel = get_loglevel_by_name(conf.loglevel_arg); } - loglevel = get_loglevel_by_name(conf.loglevel_arg); if (conf.socket_given) socket_name = para_strdup(conf.socket_arg); else { @@@ -336,16 -330,21 +346,16 @@@ interactive_session(); args = concat_args(conf.inputs_num, conf.inputs); - ret = connect_local_socket(socket_name); + ret = connect_audiod(socket_name, args); free(socket_name); - if (ret < 0) { - PARA_EMERG_LOG("failed to connect to local socket\n"); + if (ret < 0) goto out; - } fd = ret; - ret = send_cred_buffer(fd, args); + ret = mark_fd_blocking(STDOUT_FILENO); if (ret < 0) goto out; bufsize = conf.bufsize_arg; buf = para_malloc(bufsize); - ret = mark_fd_blocking(STDOUT_FILENO); - if (ret < 0) - goto out; do { size_t n = ret = recv_bin_buffer(fd, buf, bufsize); if (ret <= 0) diff --combined client.c index 8657b3aa,3587a971..2d6ef31f --- a/client.c +++ b/client.c @@@ -445,9 -445,11 +445,9 @@@ static int client_i9e_line_handler(cha int ret; client_disconnect(ct); - if (!line || !*line) - return 0; - PARA_DEBUG_LOG("line handler: %s\n", line); + PARA_DEBUG_LOG("line: %s\n", line); ret = make_client_argv(line); - if (ret < 0) + if (ret <= 0) return ret; ret = client_connect(ct, &sched, NULL, NULL); if (ret < 0) @@@ -475,7 -477,7 +475,7 @@@ __noreturn static void interactive_sess .completers = completers, }; - PARA_NOTICE_LOG("\n%s\n", VERSION_TEXT("client")); + PARA_NOTICE_LOG("\n%s\n", version_text("client")); if (ct->conf.history_file_given) history_file = para_strdup(ct->conf.history_file_arg); else { diff --combined compress_filter.c index f591123a,f6108c75..0c0200e7 --- a/compress_filter.c +++ b/compress_filter.c @@@ -74,23 -74,18 +74,23 @@@ next_buffer op = para_malloc(length); for (i = 0; i < length / 2; i++) { /* be careful in that heat, my dear */ - int sample = *ip++, adjusted_sample = (PARA_ABS(sample) * - pcd->current_gain) >> gain_shift; - if (adjusted_sample > 32767) { /* clip */ - PARA_NOTICE_LOG("clip: sample: %d, adjusted sample: %d\n", - sample, adjusted_sample); - adjusted_sample = 32767; + int sample = *ip++; + bool neg = false; + + if (sample < 0) { + sample = -sample; + neg = true; + } + sample *= pcd->current_gain; + sample >>= gain_shift; + if (sample > 32767) { /* clip */ + sample = 32767; pcd->current_gain = (3 * pcd->current_gain + (1 << pcd->conf->inertia_arg)) / 4; pcd->peak = 0; - } else - pcd->peak = PARA_MAX(pcd->peak, adjusted_sample); - op[i] = sample >= 0? adjusted_sample : -adjusted_sample; + } else if (sample > pcd->peak) + pcd->peak = sample; + op[i] = neg? -sample : sample; if (++pcd->num_samples & mask) continue; // PARA_DEBUG_LOG("gain: %u, peak: %u\n", pcd->current_gain, @@@ -158,8 -153,5 +158,5 @@@ void compress_filter_init(struct filte f->post_select = compress_post_select; f->parse_config = compress_parse_config; f->free_config = compress_free_config; - f->help = (struct ggo_help) { - .short_help = compress_filter_args_info_help, - .detailed_help = compress_filter_args_info_detailed_help - }; + f->help = (struct ggo_help)DEFINE_GGO_HELP(compress_filter); } diff --combined gui.c index 0361347e,4d2c9f72..baab0bd9 --- a/gui.c +++ b/gui.c @@@ -23,6 -23,7 +23,7 @@@ #include "list.h" #include "sched.h" #include "signal.h" + #include "ggo.h" #include "version.h" /** define the array of error lists needed by para_gui */ @@@ -293,7 -294,7 +294,7 @@@ static char *configfile_exists(void static void add_spaces(WINDOW* win, unsigned int num) { char space[] = " "; - unsigned sz = sizeof(space); + unsigned sz = sizeof(space) - 1; /* number of spaces */ while (num >= sz) { waddstr(win, space); @@@ -604,8 -605,8 +605,8 @@@ static void print_welcome(void { if (loglevel > LL_NOTICE) return; - outputf(COLOR_WELCOME, "Welcome to para_gui " PACKAGE_VERSION - " \"" CODENAME "\". Theme: %s", theme.name); + outputf(COLOR_WELCOME, "Welcome to %s. Theme: %s", + version_single_line("gui"), theme.name); wclrtoeol(bot.win); } @@@ -1362,10 -1363,7 +1363,7 @@@ static void com_reread_conf(void } PARA_INFO_LOG("rereading command line options and config file"); gui_cmdline_parser_ext(_argc, _argv, &conf, ¶ms); - if (gui_cmdline_parser_config_file(cf, &conf, ¶ms) != 0) { - PARA_EMERG_LOG("errors in config file"); - finish(EXIT_FAILURE); - } + gui_cmdline_parser_config_file(cf, &conf, ¶ms); PARA_NOTICE_LOG("config file reloaded"); if (check_key_map_args() < 0) finish(EXIT_FAILURE); @@@ -1434,8 -1432,7 +1432,7 @@@ static void com_enlarge_top_win(void static void com_version(void) { - print_in_bar(COLOR_MSG, "para_gui " PACKAGE_VERSION " \"" - CODENAME "\""); + print_in_bar(COLOR_MSG, "%s", version_single_line("gui")); } __noreturn static void com_quit(void) @@@ -1514,6 -1511,15 +1511,15 @@@ static void handle_command(int c km_keyname(c)); } + __noreturn static void print_help_and_die(void) + { + struct ggo_help h = DEFINE_GGO_HELP(gui); + 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; @@@ -1523,7 -1529,10 +1529,10 @@@ _argv = argv; gui_cmdline_parser(argc, argv, &conf); /* exits on errors */ - HANDLE_VERSION_FLAG("gui", conf); + loglevel = get_loglevel_by_name(conf.loglevel_arg); + version_handle_flag("gui", conf.version_given); + if (conf.help_given || conf.detailed_help_given) + print_help_and_die(); cf = configfile_exists(); if (!cf && conf.config_file_given) { fprintf(stderr, "can not read config file %s\n", @@@ -1538,10 -1547,9 +1547,9 @@@ .check_ambiguity = 0, .print_errors = 1, }; - if (gui_cmdline_parser_config_file(cf, &conf, ¶ms) != 0) - exit(EXIT_FAILURE); + gui_cmdline_parser_config_file(cf, &conf, ¶ms); + loglevel = get_loglevel_by_name(conf.loglevel_arg); } - loglevel = get_loglevel_by_name(conf.loglevel_arg); if (check_key_map_args() < 0) { fprintf(stderr, "invalid key map\n"); exit(EXIT_FAILURE); diff --combined play.c index 02128af0,e6a58fce..6eed58ab --- a/play.c +++ b/play.c @@@ -137,30 -137,14 +137,14 @@@ static void check_afh_receiver_or_die(v exit(EXIT_FAILURE); } - /** Description to be included in the --detailed-help output. */ - #define PP_DESC \ - "para_play is a command line audio player.\n" \ - "\n" \ - "It operates either in command mode or in insert mode. In insert mode it\n" \ - "presents a prompt and allows to enter para_play commands like stop, play, pause\n" \ - "etc. In command mode, the current audio file is shown and the program reads\n" \ - "single key strokes from stdin. Keys may be mapped to para_play commands.\n" \ - "Whenever a mapped key is pressed, the associated command is executed.\n" \ - __noreturn static void print_help_and_die(void) { - int d = conf.detailed_help_given; - const char **p = d? play_args_info_detailed_help - : play_args_info_help; - - // printf_or_die("%s\n\n", PLAY_CMDLINE_PARSER_PACKAGE "-" - // PLAY_CMDLINE_PARSER_VERSION); - - printf_or_die("%s\n\n", play_args_info_usage); - if (d) - printf_or_die("%s\n", PP_DESC); - for (; *p; p++) - printf_or_die("%s\n", *p); + struct ggo_help help = DEFINE_GGO_HELP(play); + unsigned flags = conf.detailed_help_given? + GPH_STANDARD_FLAGS_DETAILED : GPH_STANDARD_FLAGS; + + ggo_print_help(&help, flags); + printf("supported audio formats: %s\n", AUDIO_FORMAT_HANDLERS); exit(0); } @@@ -176,12 -160,11 +160,11 @@@ static void parse_config_or_die(int arg .print_errors = 1 }; - if (play_cmdline_parser_ext(argc, argv, &conf, ¶ms)) - exit(EXIT_FAILURE); - HANDLE_VERSION_FLAG("play", conf); + play_cmdline_parser_ext(argc, argv, &conf, ¶ms); + loglevel = get_loglevel_by_name(conf.loglevel_arg); + version_handle_flag("play", conf.version_given); if (conf.help_given || conf.detailed_help_given) print_help_and_die(); - loglevel = get_loglevel_by_name(conf.loglevel_arg); if (conf.config_file_given) config_file = para_strdup(conf.config_file_arg); else { @@@ -198,6 -181,7 +181,7 @@@ params.initialize = 0; params.check_required = 1; play_cmdline_parser_config_file(config_file, &conf, ¶ms); + loglevel = get_loglevel_by_name(conf.loglevel_arg); } for (i = 0; i < conf.key_map_given; i++) { char *s = strchr(conf.key_map_arg[i] + 1, ':'); @@@ -990,7 -974,15 +974,7 @@@ out static int play_i9e_line_handler(char *line) { - struct play_task *pt = &play_task; - int ret; - - if (line == NULL || !*line) - return 0; - ret = run_command(line, pt); - if (ret < 0) - return ret; - return 0; + return run_command(line, &play_task); } static int play_i9e_key_handler(int key) @@@ -1036,7 -1028,7 +1020,7 @@@ static void session_open(__a_unused str char *history_file; struct sigaction act; - PARA_NOTICE_LOG("\n%s\n", VERSION_TEXT("play")); + PARA_NOTICE_LOG("\n%s\n", version_text("play")); if (conf.history_file_given) history_file = para_strdup(conf.history_file_arg); else {