[Pkg-wmaker-commits] [wmix] 03/10: Import Upstream version 3.1

Doug Torrance dtorrance-guest at moszumanska.debian.org
Fri Sep 29 02:16:30 UTC 2017


This is an automated email from the git hooks/post-receive script.

dtorrance-guest pushed a commit to branch master
in repository wmix.

commit ef4ee76910ebd533d5acff25d893b20287dfba9f
Author: Doug Torrance <dtorrance at piedmont.edu>
Date:   Thu Sep 28 22:02:03 2017 -0400

    Import Upstream version 3.1
---
 NEWS            | 10 ++++++++++
 include/mixer.h |  6 +++++-
 mixer-oss.c     | 38 +++++++++++++++++++++++++++-----------
 ui_x.c          |  3 ++-
 wmix.c          | 24 ++++++++++++++++++++++--
 5 files changed, 66 insertions(+), 15 deletions(-)

diff --git a/NEWS b/NEWS
index 4ee3f7d..bea62a5 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,13 @@
+3.1 NEWS:
+Fixed a 3 years old bug about volume level showing up as "0" when it's
+actually set to 10. Thank to all 20 or so people who e-mailed me about this.
+Changed struct mixer_info name to allow compiling wmix under 2.6.1+ kernels.
+Thanks Neil Burch <burch at cs.ualberta.ca> for the patch.
+Added a patch to enable exclusion of channels from display - allows you to
+remove mixer channels you never use. adds '-e <channame>' command line option
+which can be repeated any number of times. Thanks to Nicolas Descomps <nico_206 at noos.fr>.
+Added #include <string.h> since glibc finally fixed most of the includes since 2001.
+
 3.0 NEWS:
 Major code rewrite. Now uses much better mixer library. New knob drawing code.
 New config parsing code - no more segfaults. New mouse control code for knob
diff --git a/include/mixer.h b/include/mixer.h
index b5680d7..d5746ea 100644
--- a/include/mixer.h
+++ b/include/mixer.h
@@ -55,7 +55,9 @@
  * - Muting must occur independently of the volume level.
  */
 
-void		mixer_init			(const char *mixer_device, bool verbose);
+void		mixer_init			(const char *mixer_device,
+						 bool verbose,
+						 const char *exclude[]);
 bool		mixer_is_changed		(void);
 int		mixer_get_channel_count		(void);
 int		mixer_get_channel		(void);
@@ -75,3 +77,5 @@ bool		mixer_is_muted			(void);
 bool		mixer_is_stereo			(void);
 bool		mixer_is_rec			(void);
 bool		mixer_can_rec			(void);
+bool            is_exclude                      (const char *short_name,
+						 const char *exclude[]);
diff --git a/mixer-oss.c b/mixer-oss.c
index 51b13b2..6bdbe1e 100644
--- a/mixer-oss.c
+++ b/mixer-oss.c
@@ -25,6 +25,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <fcntl.h>
+#include <string.h>
 #include <assert.h>
 #include <sys/ioctl.h>
 #include <sys/soundcard.h>
@@ -93,7 +94,7 @@ static int prev_modify_counter = -1;
 
 static bool get_mixer_state(void)
 {
-    struct mixer_info mixer_info;
+    struct mixer_info m_info;
     int dev_lr_volume, dev_left_volume, dev_right_volume;
     float left, right;
     int srcmask;
@@ -102,9 +103,9 @@ static bool get_mixer_state(void)
     /* to really keep track of updates */
     static MixerChannel oldmixer[SOUND_MIXER_NRDEVICES];
 
-    ioctl(mixer_fd, SOUND_MIXER_INFO, &mixer_info);
+    ioctl(mixer_fd, SOUND_MIXER_INFO, &m_info);
 
-    if (mixer_info.modify_counter == prev_modify_counter)
+    if (m_info.modify_counter == prev_modify_counter)
 	/*
 	 * Mixer state has not changed
 	 */
@@ -156,7 +157,7 @@ static bool get_mixer_state(void)
 	}
 	mixer[ch].is_recording = ((1 << mixer[ch].dev) & srcmask) != 0;
     }
-    prev_modify_counter = mixer_info.modify_counter;
+    prev_modify_counter = m_info.modify_counter;
     /* check if this was due to OSS stupidity or if we really changed */
     if (!memcmp(&mixer, &oldmixer, sizeof(mixer))) {
 	memcpy(&oldmixer, &mixer, sizeof(mixer));
@@ -220,10 +221,10 @@ static void set_record_state(void)
     }
 }
 
-void mixer_init(const char *mixer_device, bool verbose)
+void mixer_init(const char *mixer_device, bool verbose, const char * exclude[])
 {
     int devmask, srcmask, recmask, stmask;
-    struct mixer_info mixer_info;
+    struct mixer_info m_info;
     int count;
     int mask;
 
@@ -255,18 +256,18 @@ void mixer_init(const char *mixer_device, bool verbose)
 	exit(EXIT_FAILURE);
     }
 
-    if (ioctl(mixer_fd, SOUND_MIXER_INFO, &mixer_info) == -1) {
+    if (ioctl(mixer_fd, SOUND_MIXER_INFO, &m_info) == -1) {
 	fputs("error: could not read mixer info\n", stderr);
 	exit(EXIT_FAILURE);
     }
 
     if (verbose) {
-	printf("%s (%s)\n", mixer_info.name, mixer_info.id);
+	printf("%s (%s)\n", m_info.name, m_info.id);
 	puts("Supported channels:");
     }
     for (count = 0; count < SOUND_MIXER_NRDEVICES; count++) {
 	mask = 1 << count;
-	if (mask & devmask) {
+	if ((mask & devmask) && (!is_exclude((short_names[count]),exclude))) {
 	    mixer[n_channels].name = channel_names[count];
 	    mixer[n_channels].sname = short_names[count];
 	    mixer[n_channels].dev = count;
@@ -277,8 +278,12 @@ void mixer_init(const char *mixer_device, bool verbose)
 	    mixer[n_channels].is_muted = false;
 	    ++n_channels;
 	    if (verbose)
-		printf("  %d: %s\n", n_channels, channel_names[count]);
-	}
+		printf("  %d: %s \t(%s)\n", n_channels, 
+		       channel_names[count],
+		       short_names[count]);    
+	} else if ((mask & devmask) && verbose)
+	  printf("  x: %s \t(%s) - disabled\n", channel_names[count],
+		 short_names[count]);
     }
     get_mixer_state();
 }
@@ -406,3 +411,14 @@ bool mixer_can_rec(void)
 {
     return mixer[cur_channel].can_record;
 }
+
+bool is_exclude(const char *short_name, const char *exclude[])
+{
+  int count = 0;
+  while (count < SOUND_MIXER_NRDEVICES && exclude[count] != NULL){
+    if ( strcmp(short_name, exclude[count]) == 0 )
+      return true;
+    count++;
+  }
+  return false;
+}
diff --git a/ui_x.c b/ui_x.c
index 9d7c2fa..cf85e1d 100644
--- a/ui_x.c
+++ b/ui_x.c
@@ -24,6 +24,7 @@
 
 #include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
 #include <ctype.h>
 #include <math.h>
 
@@ -516,7 +517,7 @@ static void draw_percent(void)
     copy_xpm_area(0, 87, 18, 9, 41, 22);	/* clear percentage */
     
     if (volume < 100) {
-	if (volume > 10)
+	if (volume >= 10)
 	    copy_xpm_area((volume / 10) * 6, 67, 6, 9, 47, 22);
 	copy_xpm_area((volume % 10) * 6, 67, 6, 9, 53, 22);
     } else {
diff --git a/wmix.c b/wmix.c
index eac439b..1fbf9db 100644
--- a/wmix.c
+++ b/wmix.c
@@ -31,6 +31,8 @@
 #include <X11/Xlib.h>
 #include <X11/Xutil.h>
 
+#include <sys/soundcard.h>
+
 #include "include/common.h"
 #include "include/mixer.h"
 #include "include/misc.h"
@@ -51,6 +53,8 @@ Config config;
 static int mouse_drag_home_x;
 static int mouse_drag_home_y;
 static int idle_loop;
+static bool verbose;
+static char *exclude[SOUND_MIXER_NRDEVICES];
 
 /* local stuff */
 static void parse_cli_options(int argc, char **argv);
@@ -66,12 +70,16 @@ static void motion_event(XMotionEvent *event);
 	"  -f <file> parse this config [~/.wmixrc]\n" \
 	"  -m <dev>  mixer device [/dev/mixer]\n" \
 	"  -h        print this help\n" \
+	"  -v        verbose -> id, long name, name\n" \
+	"  -e <name> exclude channel, can be used many times\n" \
 
 static void parse_cli_options(int argc, char **argv)
 {
     int opt;
+    int count_exclude = 0 ;
+    verbose = false ;
 
-    while ((opt = getopt(argc, argv, "d:f:hm:")) != EOF) {
+    while ((opt = getopt(argc, argv, "d:f:hm:ve:")) != EOF) {
 	switch (opt) {
 	    case 'd':
 		if (optarg != NULL)
@@ -91,10 +99,22 @@ static void parse_cli_options(int argc, char **argv)
 		fputs(HELP_TEXT, stdout);
 		exit(0);
 		break;
+   	    case 'v':
+	        verbose = true;
+		break;
+   	    case 'e':
+		if (count_exclude < SOUND_MIXER_NRDEVICES) {
+		    exclude[count_exclude] = strdup(optarg);
+		    /* printf("exclude : %s\n", exclude[count_exclude]); */
+		    count_exclude++;
+		} else
+		    fprintf(stderr, "Warning: You can't exclude this many channels\n");
+		break;
 	    default:
 		break;
 	}
     }
+    exclude[count_exclude] = NULL ;
 }
 
 int main(int argc, char **argv)
@@ -138,7 +158,7 @@ int main(int argc, char **argv)
     if (mixer_device == NULL)
 	mixer_device = "/dev/mixer";
 
-    mixer_init(mixer_device, false);
+    mixer_init(mixer_device, verbose, (const char **)exclude);
     mixer_set_channel(0);
 
     if ((display = XOpenDisplay(display_name)) == NULL) {

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