2 * Copyright (C) 2012 Andre Noll <maan@systemlinux.org>
4 * Licensed under the GPL v2. For licencing details see COPYING.
7 /** \file play.c Paraslash's standalone player. */
13 #include "play.cmdline.h"
14 #include "filter.cmdline.h"
17 #include "buffer_tree.h"
25 #include "write_common.h"
28 static struct play_args_info conf
;
30 /** Initialize the array of errors for para_play. */
33 /* Activate the afh receiver. */
34 extern void afh_recv_init(struct receiver
*r
);
36 #define AFH_RECEIVER {.name = "afh", .init = afh_recv_init},
37 DEFINE_RECEIVER_ARRAY
;
39 /* FIXME: This is needed by the amp filter. */
40 char *stat_item_values
[NUM_STAT_ITEMS
] = {NULL
};
42 static int loglevel
= LL_WARNING
;
43 INIT_STDERR_LOGGING(loglevel
);
45 __noreturn
static void print_help_and_die(void)
47 int d
= conf
.detailed_help_given
;
48 const char **p
= d
? play_args_info_detailed_help
49 : play_args_info_help
;
51 printf_or_die("%s\n\n", PLAY_CMDLINE_PARSER_PACKAGE
"-"
52 PLAY_CMDLINE_PARSER_VERSION
);
53 printf_or_die("%s\n\n", play_args_info_usage
);
55 printf_or_die("%s\n", *p
);
56 print_filter_helps(d
);
57 print_writer_helps(d
);
61 static void parse_config_or_die(int argc
, char *argv
[])
65 struct play_cmdline_parser_params params
= {
73 if (play_cmdline_parser_ext(argc
, argv
, &conf
, ¶ms
))
75 HANDLE_VERSION_FLAG("play", conf
);
76 if (conf
.help_given
|| conf
.detailed_help_given
)
78 loglevel
= get_loglevel_by_name(conf
.loglevel_arg
);
79 if (conf
.config_file_given
)
80 config_file
= para_strdup(conf
.config_file_arg
);
82 char *home
= para_homedir();
83 config_file
= make_message("%s/.paraslash/play.conf", home
);
86 ret
= file_exists(config_file
);
87 if (conf
.config_file_given
&& !ret
) {
88 PARA_EMERG_LOG("can not read config file %s\n", config_file
);
92 params
.initialize
= 0;
93 params
.check_required
= 1;
94 play_cmdline_parser_config_file(config_file
, &conf
, ¶ms
);
103 int main(int argc
, char *argv
[])
105 /* needed this early to make help work */
110 parse_config_or_die(argc
, argv
);