Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 8 Mar 1998 03:20:13 -0300 (EST)
From:      Joao Carlos Mendes Luis <jonny@coppe.ufrj.br>
To:        FreeBSD-gnats-submit@FreeBSD.ORG
Subject:   bin/5943: multi-device suport to mixer(8)
Message-ID:  <199803080620.DAA21620@gaia.coppe.ufrj.br>

next in thread | raw e-mail | index | archive | help

>Number:         5943
>Category:       bin
>Synopsis:       multi-device suport to mixer(8)
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:
>Keywords:
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sat Mar  7 22:30:02 PST 1998
>Last-Modified:
>Originator:     Joao Carlos Mendes Luis
>Organization:
COPPE/UFRJ
>Release:        FreeBSD 2.2.5-STABLE i386
>Environment:

	Any FreeSD with more than one soundcard installed.

>Description:

	The current -stable /usr/sbin/mixer does not have a
	way to specify multiple devices.  Also, there's a
	small misinterpretation on the man page.

>How-To-Repeat:

	Try to change the mixer configuration of /dev/mixer1.  :)

>Fix:
	
Here are some patches, with the following characteristics:

1) Support for mixer device specification, with -d flag
2) Cite the new sintax in the manual.  There was a misinterpretation
   on this subject previously.  In the command "mixer +rec dev", dev
   is a recording source and not a device.  Change names to avoid
   confusion.
3) -Wall clean
4) getopt clean

--- mixer.8.old	Sun Mar  8 02:57:01 1998
+++ mixer.8	Sun Mar  8 03:09:55 1998
@@ -34,11 +34,13 @@
 .Sh SYNOPSIS
 .Nm
 .Nm mixer
+.Op Fl d Ar dev
 .Ar setting
 .Op Ar lvalue:rvalue
 .Nm mixer
+.Op Fl d Ar dev
 .Ar +rec | -rec
-.Op Ar device
+.Op Ar source
 .Sh DESCRIPTION
 The
 .Nm
@@ -78,10 +80,12 @@
 argument.  To stop recording, use the
 .Ar -rec 
 argument.  The optional argument
-.Ar device
-may be specified to use a different
-mixer device.  The default device is
-.Pa /dev/mixer .
+.Ar source
+may be specified to select where to record from.
+.Pp
+The optional flag
+.Fl d
+may be specified to use a different mixer device.
 .Sh FILES
 .Bl -tag -width /dev/mixer -compact
 .It Pa /dev/mixer
--- mixer.c.old	Sun Mar  8 02:56:49 1998
+++ mixer.c	Sun Mar  8 03:09:45 1998
@@ -18,12 +18,16 @@
 #include <fcntl.h>
 #include <stdio.h>
 #include <string.h>
+#include <unistd.h>
+#include <stdlib.h>
 #ifdef __FreeBSD__
 #include <machine/soundcard.h>
 #else
 #include <sys/soundcard.h>
 #endif
 
+#define	DEFAULT_DEV	"/dev/mixer"
+
 char *names[SOUND_MIXER_NRDEVICES] = SOUND_DEVICE_NAMES;
 
 int devmask = 0, recmask = 0, recsrc = 0;
@@ -31,7 +35,7 @@
 void usage(void)
 {
 	int i, n = 0;
-	printf("usage: mixer { ");
+	printf("usage: mixer [-d dev] { ");
 
 	for (i = 0; i < SOUND_MIXER_NRDEVICES; i++)
 		if ((1 << i) & devmask)  {
@@ -40,7 +44,7 @@
 			printf(names[i]);
 			n = 1;
 		}
-	printf(" } <value>\n  or   mixer { +rec|-rec } <devicename>\n");
+	printf(" } <value>\n  or   mixer [-d dev] { +rec|-rec } <source>\n");
 	exit(1);
 }
 
@@ -63,14 +67,26 @@
 main(int argc, char *argv[])
 {
 	int foo, bar, baz, dev;
-
-	char name[30] = "/dev/mixer";
-
-	if (!strcmp(argv[0], "mixer2"))
-	   strcpy(name, "/dev/mixer1");
-	else
-	  if (!strcmp(argv[0], "mixer3"))
-	     strcpy(name, "/dev/mixer2");
+	char *name = DEFAULT_DEV;
+	int ch;
+	extern char *optarg;
+	extern int optind;
+
+	while ( ( ch = getopt( argc, argv, "hd:" ) ) != -1 ) {
+	  switch ( ch ) {
+	    case 'h':
+	      usage();
+	      /* NOTREACHED */
+	    case 'd':
+	      name = optarg;
+	      break;
+	    case '?':
+	    default:
+	      usage();
+	  }
+	}
+	argc -= optind - 1;
+	argv += optind - 1;
 
 	if ((baz = open(name, O_RDWR)) < 0)
 		err(1, "%s", name);
@@ -166,4 +182,5 @@
 	}
 
 	close(baz);
+	return (0);
 }
>Audit-Trail:
>Unformatted:

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199803080620.DAA21620>