+ ret = m->set_channel(h, conf.mixer_channel_arg);
+ if (ret >= 0) {
+ PARA_NOTICE_LOG("using %s mixer channel\n",
+ conf.mixer_channel_arg? conf.mixer_channel_arg
+ : "default");
+ return ret;
+ }
+ channels = m->get_channels(h);
+ printf("Available channels: %s\n", channels);
+ free(channels);
+ return ret;
+}
+
+static struct mixer *get_mixer_or_die(void)
+{
+ int i;
+
+ if (!conf.mixer_api_given)
+ i = DEFAULT_MIXER;
+ else
+ FOR_EACH_MIXER(i)
+ if (!strcmp(mixer_name[i], conf.mixer_api_arg))
+ break;
+ if (i < NUM_SUPPORTED_MIXERS) {
+ PARA_NOTICE_LOG("using %s mixer API\n", mixer_name[i]);
+ return supported_mixer + i;
+ }
+ printf("available mixer APIs: ");
+ FOR_EACH_MIXER(i) {
+ int d = (i == DEFAULT_MIXER);
+ printf("%s%s%s ", d? "[" : "", mixer_name[i], d? "]" : "");
+ }
+ printf("\n");
+ 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;
+
+ 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();