[Pkg-wmaker-commits] [wmix] 40/44: Allow sound api to be specified in the config file

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 2757a935be0b420fff8a518a63f25eba348ac102
Author: Johannes Holmberg <johannes at update.uu.se>
Date:   Wed Sep 16 21:19:47 2015 -0400

    Allow sound api to be specified in the config file
---
 config.c         | 22 ++++++++++++++++++----
 include/config.h |  2 +-
 2 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/config.c b/config.c
index 8fdb293..0b80013 100644
--- a/config.c
+++ b/config.c
@@ -66,7 +66,7 @@ const char default_osd_color[] = "green";
 void config_init(void)
 {
 	memset(&config, 0, sizeof(config));
-        config.api = 0;
+        config.api = -1;
 	config.mixer_device = NULL;
 	config.mousewheel = 1;
 	config.scrolltext = 1;
@@ -163,8 +163,10 @@ void parse_cli_options(int argc, char **argv)
 		case 'a':
 			if(!strcmp("oss", optarg))
 				config.api = 1;
-			else if (strcmp("alsa", optarg))
-				fprintf(stderr, "Warning: Incorrect sound api specified, defaulting to alsa\n");
+			else if (!strcmp("alsa", optarg))
+				config.api = 0;
+			else
+				fprintf(stderr, "wmix:warning: incorrect sound api specified on command line, ignoring\n");
 			break;
 		case 'd':
 			if (config.display_name)
@@ -325,7 +327,16 @@ void config_read(void)
 		*ptr = '\0';
 
 		/* Check what keyword we have */
-		if (strcmp(keyword, "device") == 0) {
+		if (strcmp(keyword, "api") == 0) {
+			if (config.api == -1) {
+				if(!strcmp("oss", value))
+					config.api = 1;
+				else if (!strcmp("alsa", value))
+					config.api = 0;
+				else
+					fprintf(stderr, "wmix:warning: incorrect sound api in config, ignoring\n");
+			}
+		} else if (strcmp(keyword, "device") == 0) {
 			if (config.mixer_device == default_mixer_device)
 				config.mixer_device = strdup(value);
 			/* If not the default, keep the previous value because it was provided in the command-line */
@@ -393,6 +404,9 @@ void config_read(void)
 
 void config_set_defaults()
 {
+	if (config.api == -1)
+		config.api = 0;
+
 	if (!config.mixer_device) {
 		if (config.api == 0)
 			config.mixer_device = (char *)default_card_name;
diff --git a/include/config.h b/include/config.h
index 7570fcd..d916fa2 100644
--- a/include/config.h
+++ b/include/config.h
@@ -28,7 +28,7 @@ extern struct _Config {
 	char        *display_name;		/* X Display to connect to */
 	char        *mixer_device;		/* device file to use for controlling Mixer volumes */
 
-	unsigned int api;               /* Sound API (0 = ALSA, 1 = OSS) */
+	int api;                        /* Sound API (0 = ALSA, 1 = OSS) */
 	unsigned int verbose    : 1;	/* be Verbose when starting */
 	unsigned int osd        : 1;	/* show OSD? */
 	unsigned int mousewheel : 1;	/* mousewheel enabled? */

-- 
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