[Pkg-wmaker-commits] [wmix] 39/44: Better handling of configuration defaults for the new settings
Doug Torrance
dtorrance-guest at moszumanska.debian.org
Fri Sep 29 10:40:15 UTC 2017
This is an automated email from the git hooks/post-receive script.
dtorrance-guest pushed a commit to branch upstream
in repository wmix.
commit a47e89e1ce3416e9b3d994bdd610e09566daf644
Author: Johannes Holmberg <johannes at update.uu.se>
Date: Wed Sep 16 21:19:46 2015 -0400
Better handling of configuration defaults for the new settings
---
config.c | 36 +++++++++++++++++++++++-------------
include/config.h | 3 +++
wmix.c | 1 +
3 files changed, 27 insertions(+), 13 deletions(-)
diff --git a/config.c b/config.c
index 8c9490d..8fdb293 100644
--- a/config.c
+++ b/config.c
@@ -76,7 +76,7 @@ void config_init(void)
config.scrollstep = 0.03;
config.osd = 1;
config.osd_color = (char *) default_osd_color;
- config.osd_monitor_number = 0;
+ config.osd_monitor_number = -1;
config.osd_monitor_name = NULL;
}
@@ -111,14 +111,13 @@ void config_release(void)
}
}
-void parse_monitor_value(char *value)
+bool parse_monitor_value(char *value)
{
char *end;
long mon = strtol(value, &end, 10);
if (end == value + strlen(value)) {
if ((mon > INT_MAX) || (mon < -1)) {
- fprintf(stderr, "wmix:warning: unreasonable monitor number provided, falling back to default\n");
- config.osd_monitor_number = 0;
+ return false;
} else {
if (mon == -1)
config.osd = 0;
@@ -128,6 +127,7 @@ void parse_monitor_value(char *value)
} else {
config.osd_monitor_name = strdup(value);
}
+ return true;
}
/*
@@ -203,7 +203,8 @@ void parse_cli_options(int argc, char **argv)
break;
case 'o':
- parse_monitor_value(optarg);
+ if (!parse_monitor_value(optarg))
+ fprintf(stderr, "wmix:warning: unreasonable monitor number provided on command line, ignoring\n");
break;
case 'v':
@@ -216,13 +217,6 @@ void parse_cli_options(int argc, char **argv)
}
config.exclude_channel[count_exclude] = NULL;
- if (!config.mixer_device) {
- if (config.api == 0)
- config.mixer_device = (char *)default_card_name;
- else if (config.api == 1)
- config.mixer_device = (char *)default_mixer_device;
- }
-
if (optind < argc) {
fprintf(stderr, "wmix:error: argument '%s' not understood\n", argv[optind]);
error_found = true;
@@ -361,7 +355,10 @@ void config_read(void)
config.osd_color = strdup(value);
} else if (strcmp(keyword, "osdmonitor") == 0) {
- parse_monitor_value(value);
+ if (!config.osd_monitor_name &&
+ config.osd_monitor_number == -1 &&
+ !parse_monitor_value(value))
+ fprintf(stderr, "wmix:warning: unreasonable monitor number in config, ignoring\n");
} else if (strcmp(keyword, "scrolltext") == 0) {
config.scrolltext = atoi(value);
@@ -393,3 +390,16 @@ void config_read(void)
}
fclose(fp);
}
+
+void config_set_defaults()
+{
+ if (!config.mixer_device) {
+ if (config.api == 0)
+ config.mixer_device = (char *)default_card_name;
+ else if (config.api == 1)
+ config.mixer_device = (char *)default_mixer_device;
+ }
+
+ if (!config.osd_monitor_name && config.osd_monitor_number == -1)
+ config.osd_monitor_number = 0;
+}
diff --git a/include/config.h b/include/config.h
index 9d73668..7570fcd 100644
--- a/include/config.h
+++ b/include/config.h
@@ -64,4 +64,7 @@ void parse_cli_options(int argc, char **argv);
/* Read configuration from file */
void config_read(void);
+/* Set some default values based on configuration choices */
+void config_set_defaults();
+
#endif /* WMIX_CONFIG_H */
diff --git a/wmix.c b/wmix.c
index c0ef6ba..a2020c3 100644
--- a/wmix.c
+++ b/wmix.c
@@ -71,6 +71,7 @@ int main(int argc, char **argv)
config_init();
parse_cli_options(argc, argv);
config_read();
+ config_set_defaults();
choose_api(config.api);
mixer_init(config.mixer_device, config.verbose, (const char **)config.exclude_channel);
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-wmaker/wmix.git
More information about the Pkg-wmaker-commits
mailing list