CVS commit: src/usr.bin/audiocfg

2021-06-20 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Jun 21 03:04:27 UTC 2021

Modified Files:
src/usr.bin/audiocfg: drvctl.c

Log Message:
fix proplib deprecation


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/audiocfg/drvctl.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/audiocfg/drvctl.c
diff -u src/usr.bin/audiocfg/drvctl.c:1.2 src/usr.bin/audiocfg/drvctl.c:1.3
--- src/usr.bin/audiocfg/drvctl.c:1.2	Wed Sep  1 22:17:35 2010
+++ src/usr.bin/audiocfg/drvctl.c	Sun Jun 20 23:04:27 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: drvctl.c,v 1.2 2010/09/02 02:17:35 jmcneill Exp $ */
+/* $NetBSD: drvctl.c,v 1.3 2021/06/21 03:04:27 christos Exp $ */
 
 /*
  * Copyright (c) 2010 Jared D. McNeill 
@@ -64,9 +64,9 @@ drvctl_get_properties(int fd, const char
 	command_dict = prop_dictionary_create();
 	args_dict = prop_dictionary_create();
 
-	prop_dictionary_set_cstring_nocopy(command_dict, "drvctl-command",
+	prop_dictionary_set_string_nocopy(command_dict, "drvctl-command",
 	"get-properties");
-	prop_dictionary_set_cstring_nocopy(args_dict, "device-name", devnode);
+	prop_dictionary_set_string_nocopy(args_dict, "device-name", devnode);
 	prop_dictionary_set(command_dict, "drvctl-arguments", args_dict);
 	prop_object_release(args_dict);
 
@@ -115,7 +115,7 @@ drvctl_search(int fd, const char *curnod
 		rv = drvctl_get_properties(fd, laa.l_childname[i], );
 		if (rv == false || props == NULL)
 			continue;
-		rv = prop_dictionary_get_cstring_nocopy(props,
+		rv = prop_dictionary_get_string(props,
 		"device-driver", );
 		if (rv == true && strcmp(curdvname, dvname) == 0) {
 			rv = prop_dictionary_get_uint32(props,



CVS commit: src/usr.bin/audiocfg

2021-04-07 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Wed Apr  7 09:58:58 UTC 2021

Modified Files:
src/usr.bin/audiocfg: audiocfg.1

Log Message:
audiocfg(1): add examples


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/usr.bin/audiocfg/audiocfg.1

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/audiocfg/audiocfg.1
diff -u src/usr.bin/audiocfg/audiocfg.1:1.7 src/usr.bin/audiocfg/audiocfg.1:1.8
--- src/usr.bin/audiocfg/audiocfg.1:1.7	Mon Oct 19 21:46:15 2020
+++ src/usr.bin/audiocfg/audiocfg.1	Wed Apr  7 09:58:58 2021
@@ -1,4 +1,4 @@
-.\"	$NetBSD: audiocfg.1,v 1.7 2020/10/19 21:46:15 dholland Exp $
+.\"	$NetBSD: audiocfg.1,v 1.8 2021/04/07 09:58:58 nia Exp $
 .\"
 .\" Copyright (c) 2010 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -27,7 +27,7 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd October 19, 2020
+.Dd April 7, 2021
 .Dt AUDIOCFG 1
 .Os
 .Sh NAME
@@ -120,6 +120,12 @@ see
 .It Pa /dev/sound[0-9]*
 Available audio devices.
 .El
+.Sh EXAMPLES
+Configure audio device 0 for playing BluRay 5.1 surround sound:
+.Dl $ audiocfg set 0 p slinear_le 16 6 48000
+.Pp
+Configure audio device 0 for playing CD quality audio:
+.Dl $ audiocfg set 0 p slinear_le 16 2 44100
 .Sh SEE ALSO
 .Xr audioplay 1 ,
 .Xr audiorecord 1 ,



CVS commit: src/usr.bin/audiocfg

2020-10-19 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Mon Oct 19 21:46:15 UTC 2020

Modified Files:
src/usr.bin/audiocfg: audiocfg.1

Log Message:
Add missing HISTORY and AUTHORS. Bump date.

Noticed by qjsgkem on freenode.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/usr.bin/audiocfg/audiocfg.1

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/audiocfg/audiocfg.1
diff -u src/usr.bin/audiocfg/audiocfg.1:1.6 src/usr.bin/audiocfg/audiocfg.1:1.7
--- src/usr.bin/audiocfg/audiocfg.1:1.6	Sat Aug 24 06:13:01 2019
+++ src/usr.bin/audiocfg/audiocfg.1	Mon Oct 19 21:46:15 2020
@@ -1,4 +1,4 @@
-.\"	$NetBSD: audiocfg.1,v 1.6 2019/08/24 06:13:01 isaki Exp $
+.\"	$NetBSD: audiocfg.1,v 1.7 2020/10/19 21:46:15 dholland Exp $
 .\"
 .\" Copyright (c) 2010 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -27,7 +27,7 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd May 8, 2019
+.Dd October 19, 2020
 .Dt AUDIOCFG 1
 .Os
 .Sh NAME
@@ -125,3 +125,16 @@ Available audio devices.
 .Xr audiorecord 1 ,
 .Xr audio 4 ,
 .Xr drvctl 8
+.Sh HISTORY
+The
+.Nm
+utility first appeared in
+.Nx 6.0 .
+.Sh AUTHORS
+.An -nosplit
+The
+.Nm
+utility was originally written by
+.An Jared McNeill .
+This manual page was written by
+.An Thomas Klausner .



CVS commit: src/usr.bin/audiocfg

2019-05-09 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Thu May  9 09:34:58 UTC 2019

Modified Files:
src/usr.bin/audiocfg: audiocfg.1

Log Message:
Improve wording, bump date.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/usr.bin/audiocfg/audiocfg.1

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/audiocfg/audiocfg.1
diff -u src/usr.bin/audiocfg/audiocfg.1:1.4 src/usr.bin/audiocfg/audiocfg.1:1.5
--- src/usr.bin/audiocfg/audiocfg.1:1.4	Wed May  8 14:36:12 2019
+++ src/usr.bin/audiocfg/audiocfg.1	Thu May  9 09:34:58 2019
@@ -1,4 +1,4 @@
-.\"	$NetBSD: audiocfg.1,v 1.4 2019/05/08 14:36:12 isaki Exp $
+.\"	$NetBSD: audiocfg.1,v 1.5 2019/05/09 09:34:58 wiz Exp $
 .\"
 .\" Copyright (c) 2010 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -27,7 +27,7 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd September 1, 2010
+.Dd May 8, 2019
 .Dt AUDIOCFG 1
 .Os
 .Sh NAME
@@ -62,18 +62,18 @@ default audio device.
 .Pp
 Run with
 .Dq Cm set ,
-if sets the hardware format.
+it sets the hardware format.
 The
 .Ar direction
-is represented by either of 'p'(playback) or 'r'(record), or both of them,
-indicates direction you want to set to.
+is represented by either of 'p' (playback) or 'r' (record), or both of them.
+This indicates the direction you want to set.
 The remaining parameters
 .Ar encoding ,
 .Ar precision ,
-.Ar channels
+.Ar channels ,
 and
 .Ar sample_rate
-indicate the hardware format you want to set to.
+indicate the hardware format you want to set.
 These parameters must be selected from the candidates displayed by
 .Nm
 .Cm list .



CVS commit: src/usr.bin/audiocfg

2019-05-08 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Wed May  8 14:36:12 UTC 2019

Modified Files:
src/usr.bin/audiocfg: audiocfg.1 audiodev.c audiodev.h main.c

Log Message:
Update respond to isaki-audio2 branch.
- Extend list command to display supported hardware formats.
- Add set command to set hardware format.
- Use correct /dev/audioctl instead of /dev/audio.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/audiocfg/audiocfg.1
cvs rdiff -u -r1.6 -r1.7 src/usr.bin/audiocfg/audiodev.c
cvs rdiff -u -r1.4 -r1.5 src/usr.bin/audiocfg/audiodev.h
cvs rdiff -u -r1.7 -r1.8 src/usr.bin/audiocfg/main.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/audiocfg/audiocfg.1
diff -u src/usr.bin/audiocfg/audiocfg.1:1.3 src/usr.bin/audiocfg/audiocfg.1:1.4
--- src/usr.bin/audiocfg/audiocfg.1:1.3	Wed Sep  1 09:17:31 2010
+++ src/usr.bin/audiocfg/audiocfg.1	Wed May  8 14:36:12 2019
@@ -1,4 +1,4 @@
-.\"	$NetBSD: audiocfg.1,v 1.3 2010/09/01 09:17:31 wiz Exp $
+.\"	$NetBSD: audiocfg.1,v 1.4 2019/05/08 14:36:12 isaki Exp $
 .\"
 .\" Copyright (c) 2010 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -40,6 +40,14 @@
 .Cm default
 .Ar index
 .Nm
+.Cm set
+.Ar index
+.Ar direction
+.Ar encoding
+.Ar precision
+.Ar channels
+.Ar sample_rate
+.Nm
 .Cm test
 .Ar index
 .Sh DESCRIPTION
@@ -51,6 +59,25 @@ Run with
 .Dq Cm list ,
 it lists the available audio devices and shows the currently selected
 default audio device.
+.Pp
+Run with
+.Dq Cm set ,
+if sets the hardware format.
+The
+.Ar direction
+is represented by either of 'p'(playback) or 'r'(record), or both of them,
+indicates direction you want to set to.
+The remaining parameters
+.Ar encoding ,
+.Ar precision ,
+.Ar channels
+and
+.Ar sample_rate
+indicate the hardware format you want to set to.
+These parameters must be selected from the candidates displayed by
+.Nm
+.Cm list .
+.Pp
 Called with
 .Dq Cm test ,
 it plays a tone of 2 seconds for each channel of the device with the index

Index: src/usr.bin/audiocfg/audiodev.c
diff -u src/usr.bin/audiocfg/audiodev.c:1.6 src/usr.bin/audiocfg/audiodev.c:1.7
--- src/usr.bin/audiocfg/audiodev.c:1.6	Sat Mar  5 22:10:39 2016
+++ src/usr.bin/audiocfg/audiodev.c	Wed May  8 14:36:12 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: audiodev.c,v 1.6 2016/03/05 22:10:39 mrg Exp $ */
+/* $NetBSD: audiodev.c,v 1.7 2019/05/08 14:36:12 isaki Exp $ */
 
 /*
  * Copyright (c) 2010 Jared D. McNeill 
@@ -31,6 +31,7 @@
 #include 
 #include 
 
+#include 
 #include 
 #include 
 #include 
@@ -47,51 +48,23 @@ static TAILQ_HEAD(audiodevhead, audiodev
 
 #define AUDIODEV_SAMPLE_RATE	44100
 
-static unsigned int
-audiodev_probe_pchans(struct audiodev *adev)
-{
-	audio_info_t info;
-	unsigned int nchans = 0, n;
-	int error;
-
-	AUDIO_INITINFO();
-	info.play.sample_rate = AUDIODEV_SAMPLE_RATE;
-	info.play.precision = 16;
-	info.play.encoding = AUDIO_ENCODING_SLINEAR_LE;
-	info.play.channels = 1;
-	info.mode = AUMODE_PLAY;
-	error = ioctl(adev->fd, AUDIO_SETINFO, );
-	if (error == -1)
-		return 0;
-	nchans = 1;
-
-	for (n = 2; n <= 16; n += 2) {
-		info.play.channels = n;
-		error = ioctl(adev->fd, AUDIO_SETINFO, );
-		if (error == -1)
-			break;
-		nchans = info.play.channels;
-	}
-
-	return nchans;
-}
-
 static int
 audiodev_getinfo(struct audiodev *adev)
 {
 	struct stat st;
+	struct audiofmt *f;
+	audio_format_query_t query;
+	int i;
 
-	if (stat(adev->path, ) == -1)
+	if (stat(adev->ctlpath, ) == -1)
 		return -1;
 	adev->dev = st.st_rdev;
 
-	if (stat(_PATH_AUDIO, ) != -1 && st.st_rdev == adev->dev)
+	if (stat(_PATH_AUDIOCTL, ) != -1 && st.st_rdev == adev->dev)
 		adev->defaultdev = true;
 
-	adev->fd = open(adev->path, O_RDWR);
+	adev->fd = open(adev->ctlpath, O_RDONLY);
 	if (adev->fd == -1) {
-		adev->fd = open(adev->path, O_WRONLY);
-		if (adev->fd == -1)
 			return -1;
 	}
 	if (ioctl(adev->fd, AUDIO_GETDEV, >audio_device) == -1) {
@@ -99,7 +72,29 @@ audiodev_getinfo(struct audiodev *adev)
 		return -1;
 	}
 
-	adev->pchan = audiodev_probe_pchans(adev);
+	for (i = 0; ;i++) {
+		memset(, 0, sizeof(query));
+		query.index = i;
+		if (ioctl(adev->fd, AUDIO_QUERYFORMAT, ) == -1) {
+			if (errno == ENODEV) {
+/* QUERYFORMAT not supported. */
+break;
+			}
+			if (errno == EINVAL)
+break;
+			close(adev->fd);
+			return -1;
+		}
+
+		f = calloc(1, sizeof(*f));
+		f->fmt = query.fmt;
+		TAILQ_INSERT_TAIL(>formats, f, next);
+	}
+
+	if (ioctl(adev->fd, AUDIO_GETFORMAT, >info) == -1) {
+		close(adev->fd);
+		return -1;
+	}
 
 	return 0;
 }
@@ -115,8 +110,10 @@ audiodev_add(const char *pdev, const cha
 
 	strlcpy(adev->pxname, pdev, sizeof(adev->pxname));
 	strlcpy(adev->xname, dev, sizeof(adev->xname));
-	snprintf(adev->path, sizeof(adev->path) - 1, "/dev/%s", dev);
+	snprintf(adev->path, sizeof(adev->path), "/dev/%s", dev);
+	snprintf(adev->ctlpath, sizeof(adev->ctlpath), "/dev/audioctl%d", unit);
 	adev->unit = 

CVS commit: src/usr.bin/audiocfg

2016-03-05 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Sat Mar  5 22:10:39 UTC 2016

Modified Files:
src/usr.bin/audiocfg: audiodev.c

Log Message:
if opening the audio device fails, try opening again with write-only.
this allows my playback-only usb device to be listed and tested.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/audiocfg/audiodev.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/audiocfg/audiodev.c
diff -u src/usr.bin/audiocfg/audiodev.c:1.5 src/usr.bin/audiocfg/audiodev.c:1.6
--- src/usr.bin/audiocfg/audiodev.c:1.5	Sun Aug 11 06:31:00 2013
+++ src/usr.bin/audiocfg/audiodev.c	Sat Mar  5 22:10:39 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: audiodev.c,v 1.5 2013/08/11 06:31:00 dholland Exp $ */
+/* $NetBSD: audiodev.c,v 1.6 2016/03/05 22:10:39 mrg Exp $ */
 
 /*
  * Copyright (c) 2010 Jared D. McNeill 
@@ -89,8 +89,11 @@ audiodev_getinfo(struct audiodev *adev)
 		adev->defaultdev = true;
 
 	adev->fd = open(adev->path, O_RDWR);
-	if (adev->fd == -1)
-		return -1;
+	if (adev->fd == -1) {
+		adev->fd = open(adev->path, O_WRONLY);
+		if (adev->fd == -1)
+			return -1;
+	}
 	if (ioctl(adev->fd, AUDIO_GETDEV, >audio_device) == -1) {
 		close(adev->fd);
 		return -1;



CVS commit: src/usr.bin/audiocfg

2013-08-11 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Sun Aug 11 06:31:00 UTC 2013

Modified Files:
src/usr.bin/audiocfg: Makefile audiodev.c audiodev.h dtmf.c

Log Message:
Pass WARNS=5.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/audiocfg/Makefile \
src/usr.bin/audiocfg/audiodev.h
cvs rdiff -u -r1.4 -r1.5 src/usr.bin/audiocfg/audiodev.c
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/audiocfg/dtmf.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/audiocfg/Makefile
diff -u src/usr.bin/audiocfg/Makefile:1.3 src/usr.bin/audiocfg/Makefile:1.4
--- src/usr.bin/audiocfg/Makefile:1.3	Wed Sep  1 09:04:16 2010
+++ src/usr.bin/audiocfg/Makefile	Sun Aug 11 06:31:00 2013
@@ -1,9 +1,8 @@
-# $NetBSD: Makefile,v 1.3 2010/09/01 09:04:16 jmcneill Exp $
+# $NetBSD: Makefile,v 1.4 2013/08/11 06:31:00 dholland Exp $
 
 PROG=	audiocfg
 SRCS=	audiodev.c drvctl.c dtmf.c
 SRCS+=	main.c
-WARNS=	3
 
 LDADD+=	-lprop -lm
 DPADD+=	$(LIBPROP) $(LIBM)
Index: src/usr.bin/audiocfg/audiodev.h
diff -u src/usr.bin/audiocfg/audiodev.h:1.3 src/usr.bin/audiocfg/audiodev.h:1.4
--- src/usr.bin/audiocfg/audiodev.h:1.3	Thu Sep  2 02:17:35 2010
+++ src/usr.bin/audiocfg/audiodev.h	Sun Aug 11 06:31:00 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: audiodev.h,v 1.3 2010/09/02 02:17:35 jmcneill Exp $ */
+/* $NetBSD: audiodev.h,v 1.4 2013/08/11 06:31:00 dholland Exp $ */
 
 /*
  * Copyright (c) 2010 Jared D. McNeill jmcne...@invisible.ca
@@ -45,7 +45,7 @@ struct audiodev {
 	dev_t dev;
 	bool defaultdev;
 
-	int pchan;
+	unsigned pchan;
 
 	audio_device_t audio_device;
 

Index: src/usr.bin/audiocfg/audiodev.c
diff -u src/usr.bin/audiocfg/audiodev.c:1.4 src/usr.bin/audiocfg/audiodev.c:1.5
--- src/usr.bin/audiocfg/audiodev.c:1.4	Fri Sep  3 19:20:37 2010
+++ src/usr.bin/audiocfg/audiodev.c	Sun Aug 11 06:31:00 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: audiodev.c,v 1.4 2010/09/03 19:20:37 jmcneill Exp $ */
+/* $NetBSD: audiodev.c,v 1.5 2013/08/11 06:31:00 dholland Exp $ */
 
 /*
  * Copyright (c) 2010 Jared D. McNeill jmcne...@invisible.ca
@@ -269,15 +269,19 @@ audiodev_test(struct audiodev *adev, uns
 
 	off = 0;
 	while (buflen  0) {
-		size_t wlen = info.play.buffer_size;
+		size_t wlen; 
+		ssize_t ret;
+
+		wlen = info.play.buffer_size;
 		if (wlen  buflen)
 			wlen = buflen;
-		wlen = write(adev-fd, (char *)buf + off, wlen);
-		if (wlen == -1) {
+		ret = write(adev-fd, (char *)buf + off, wlen);
+		if (ret == -1) {
 			perror(write);
 			rv = -1;
 			goto done;
 		}
+		wlen = ret;
 		off += wlen;
 		buflen -= wlen;
 	}

Index: src/usr.bin/audiocfg/dtmf.c
diff -u src/usr.bin/audiocfg/dtmf.c:1.2 src/usr.bin/audiocfg/dtmf.c:1.3
--- src/usr.bin/audiocfg/dtmf.c:1.2	Wed Sep  1 21:54:00 2010
+++ src/usr.bin/audiocfg/dtmf.c	Sun Aug 11 06:31:00 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: dtmf.c,v 1.2 2010/09/01 21:54:00 jmcneill Exp $ */
+/* $NetBSD: dtmf.c,v 1.3 2013/08/11 06:31:00 dholland Exp $ */
 
 /*
  * Copyright (c) 2010 Jared D. McNeill jmcne...@invisible.ca
@@ -45,7 +45,8 @@ dtmf_create(int16_t *buf, unsigned int s
 unsigned short sample_length, unsigned short channels,
 unsigned int chanmask, float freq1, float freq2)
 {
-	int c, i;
+	int c;
+	unsigned i;
 	size_t sample_count = sample_rate * sample_length;
 
 	for (i = 0; i  sample_count; i++) {



CVS commit: src/usr.bin/audiocfg

2010-09-03 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri Sep  3 19:20:37 UTC 2010

Modified Files:
src/usr.bin/audiocfg: audiodev.c main.c

Log Message:
return an error if testing fails, and dump the device info before running tests


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/audiocfg/audiodev.c
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/audiocfg/main.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/audiocfg/audiodev.c
diff -u src/usr.bin/audiocfg/audiodev.c:1.3 src/usr.bin/audiocfg/audiodev.c:1.4
--- src/usr.bin/audiocfg/audiodev.c:1.3	Thu Sep  2 02:17:35 2010
+++ src/usr.bin/audiocfg/audiodev.c	Fri Sep  3 19:20:37 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: audiodev.c,v 1.3 2010/09/02 02:17:35 jmcneill Exp $ */
+/* $NetBSD: audiodev.c,v 1.4 2010/09/03 19:20:37 jmcneill Exp $ */
 
 /*
  * Copyright (c) 2010 Jared D. McNeill jmcne...@invisible.ca
@@ -245,6 +245,7 @@
 	int16_t *buf;
 	size_t buflen;
 	off_t off;
+	int rv = 0;
 
 	AUDIO_INITINFO(info);
 	info.play.sample_rate = AUDIODEV_SAMPLE_RATE;
@@ -271,7 +272,12 @@
 		size_t wlen = info.play.buffer_size;
 		if (wlen  buflen)
 			wlen = buflen;
-		write(adev-fd, (char *)buf + off, wlen);
+		wlen = write(adev-fd, (char *)buf + off, wlen);
+		if (wlen == -1) {
+			perror(write);
+			rv = -1;
+			goto done;
+		}
 		off += wlen;
 		buflen -= wlen;
 	}
@@ -279,7 +285,8 @@
 	if (ioctl(adev-fd, AUDIO_DRAIN) == -1)
 		perror(ioctl AUDIO_DRAIN);
 
+done:
 	free(buf);
 
-	return 0;
+	return rv;
 }

Index: src/usr.bin/audiocfg/main.c
diff -u src/usr.bin/audiocfg/main.c:1.5 src/usr.bin/audiocfg/main.c:1.6
--- src/usr.bin/audiocfg/main.c:1.5	Thu Sep  2 02:17:35 2010
+++ src/usr.bin/audiocfg/main.c	Fri Sep  3 19:20:37 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.5 2010/09/02 02:17:35 jmcneill Exp $ */
+/* $NetBSD: main.c,v 1.6 2010/09/03 19:20:37 jmcneill Exp $ */
 
 /*
  * Copyright (c) 2010 Jared D. McNeill jmcne...@invisible.ca
@@ -26,6 +26,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
+#include assert.h
 #include errno.h
 #include fcntl.h
 #include limits.h
@@ -45,6 +46,21 @@
 	exit(EXIT_FAILURE);
 }
 
+static void
+print_audiodev(struct audiodev *adev, int i)
+{
+	assert(adev != NULL);
+
+	printf(%u: [%c] %s @ %s: ,
+	i, adev-defaultdev ? '*' : ' ',
+	adev-xname, adev-pxname);
+	printf(%s, adev-audio_device.name);
+	if (strlen(adev-audio_device.version)  0)
+		printf( %s, adev-audio_device.version);
+	printf(, %u playback channel%s\n,
+	adev-pchan, adev-pchan == 1 ?  : s);
+}
+
 int
 main(int argc, char *argv[])
 {
@@ -60,17 +76,8 @@
 
 	if (strcmp(argv[1], list) == 0) {
 		n = audiodev_count();
-		for (i = 0; i  n; i++) {
-			adev = audiodev_get(i);
-			printf(%u: [%c] %s @ %s: ,
-			i, adev-defaultdev ? '*' : ' ',
-			adev-xname, adev-pxname);
-			printf(%s, adev-audio_device.name);
-			if (strlen(adev-audio_device.version)  0)
-printf( %s, adev-audio_device.version);
-			printf(, %u playback channel%s\n,
-			adev-pchan, adev-pchan == 1 ?  : s);
-		}
+		for (i = 0; i  n; i++)
+			print_audiodev(audiodev_get(i), i);
 	} else if (strcmp(argv[1], default) == 0  argc == 3) {
 		if (*argv[2]  '0' || *argv[2]  '9')
 			usage(argv[0]);
@@ -104,9 +111,13 @@
 			fprintf(stderr, no such device\n);
 			return EXIT_FAILURE;
 		}
+		print_audiodev(adev, i);
 		for (i = 0; i  adev-pchan; i++) {
-			printf(testing channel %d...\n, i);
-			audiodev_test(adev, 1  i);
+			printf(  testing channel %d..., i);
+			fflush(stdout);
+			if (audiodev_test(adev, 1  i) == -1)
+return EXIT_FAILURE;
+			printf( done\n);
 		}
 	} else
 		usage(argv[0]);



CVS commit: src/usr.bin/audiocfg

2010-09-01 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Wed Sep  1 07:50:33 UTC 2010

Modified Files:
src/usr.bin/audiocfg: audiocfg.1

Log Message:
Mention that audiocfg also controls /dev/audioctl, /dev/mixer, and /dev/sound.
Noted by mrg.
Bump date.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/audiocfg/audiocfg.1

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/audiocfg/audiocfg.1
diff -u src/usr.bin/audiocfg/audiocfg.1:1.1 src/usr.bin/audiocfg/audiocfg.1:1.2
--- src/usr.bin/audiocfg/audiocfg.1:1.1	Tue Aug 31 14:57:26 2010
+++ src/usr.bin/audiocfg/audiocfg.1	Wed Sep  1 07:50:33 2010
@@ -1,4 +1,4 @@
-.\	$NetBSD: audiocfg.1,v 1.1 2010/08/31 14:57:26 wiz Exp $
+.\	$NetBSD: audiocfg.1,v 1.2 2010/09/01 07:50:33 wiz Exp $
 .\
 .\ Copyright (c) 2010 The NetBSD Foundation, Inc.
 .\ All rights reserved.
@@ -27,7 +27,7 @@
 .\ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\ POSSIBILITY OF SUCH DAMAGE.
 .\
-.Dd August 31, 2010
+.Dd September 1, 2010
 .Dt AUDIOCFG 1
 .Os
 .Sh NAME
@@ -39,11 +39,9 @@
 .Sh DESCRIPTION
 The
 .Nm
-utility helps maintaining a
-.Pa /dev/audio
-symlink.
+utility helps maintaining the audio and mixer device symlinks.
 Run without arguments, it lists the available audio devices and shows
-the current default audio device.
+the currently selected default audio device.
 If given an
 .Ar index
 argument, that device is set as default audio device.
@@ -61,8 +59,23 @@
 Symlink to default audio device.
 .It Pa /dev/audio[0-9]*
 Available audio devices.
+.It Pa /dev/audioctl
+Symlink to default audio control device.
+.It Pa /dev/audioctl[0-9]*
+Available audio control devices.
 .It Pa /dev/drvctl
 Used for finding the correlating audio driver to an audio device.
+.It Pa /dev/mixer
+Symlink to default mixer device.
+.It Pa /dev/mixer[0-9]*
+Available mixer devices.
+.It Pa /dev/sound
+Symlink to default audio device (for the difference to
+.Pa /dev/audio ,
+see
+.Xr audio 4 ) .
+.It Pa /dev/sound[0-9]*
+Available audio devices.
 .El
 .Sh SEE ALSO
 .Xr audioplay 1 ,



CVS commit: src/usr.bin/audiocfg

2010-09-01 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Wed Sep  1 09:04:16 UTC 2010

Modified Files:
src/usr.bin/audiocfg: Makefile audiodev.c audiodev.h main.c
Added Files:
src/usr.bin/audiocfg: dtmf.c dtmf.h

Log Message:
add support for testing audio devices. the usage of audiocfg changes:

  audiocfg list
  audiocfg default [index]
  audiocfg test [index]

'list' shows the available audio devices, 'default' sets the default
audio device, and 'test' will play a tone for 2 seconds on each
channel. example:

  $ ./audiocfg list
  0: [*] audio0: ICH2 AC97 (2 playback channels)
  1: [ ] audio1: Pseudo Audio (2 playback channels)
  $ ./audiocfg test 0
  testing channel 0...
  testing channel 1...
  $


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/audiocfg/Makefile
cvs rdiff -u -r1.1.1.1 -r1.2 src/usr.bin/audiocfg/audiodev.c \
src/usr.bin/audiocfg/audiodev.h src/usr.bin/audiocfg/main.c
cvs rdiff -u -r0 -r1.1 src/usr.bin/audiocfg/dtmf.c \
src/usr.bin/audiocfg/dtmf.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/audiocfg/Makefile
diff -u src/usr.bin/audiocfg/Makefile:1.2 src/usr.bin/audiocfg/Makefile:1.3
--- src/usr.bin/audiocfg/Makefile:1.2	Tue Aug 31 14:57:26 2010
+++ src/usr.bin/audiocfg/Makefile	Wed Sep  1 09:04:16 2010
@@ -1,9 +1,11 @@
+# $NetBSD: Makefile,v 1.3 2010/09/01 09:04:16 jmcneill Exp $
+
 PROG=	audiocfg
-SRCS=	audiodev.c drvctl.c
+SRCS=	audiodev.c drvctl.c dtmf.c
 SRCS+=	main.c
 WARNS=	3
 
-LDADD+=	-lprop
-DPADD+=	$(LIBPROP)
+LDADD+=	-lprop -lm
+DPADD+=	$(LIBPROP) $(LIBM)
 
 .include bsd.prog.mk

Index: src/usr.bin/audiocfg/audiodev.c
diff -u src/usr.bin/audiocfg/audiodev.c:1.1.1.1 src/usr.bin/audiocfg/audiodev.c:1.2
--- src/usr.bin/audiocfg/audiodev.c:1.1.1.1	Mon Aug 30 02:19:47 2010
+++ src/usr.bin/audiocfg/audiodev.c	Wed Sep  1 09:04:16 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: audiodev.c,v 1.1.1.1 2010/08/30 02:19:47 mrg Exp $ */
+/* $NetBSD: audiodev.c,v 1.2 2010/09/01 09:04:16 jmcneill Exp $ */
 
 /*
  * Copyright (c) 2010 Jared D. McNeill jmcne...@invisible.ca
@@ -40,10 +40,42 @@
 
 #include audiodev.h
 #include drvctl.h
+#include dtmf.h
 
 static TAILQ_HEAD(audiodevhead, audiodev) audiodevlist =
 TAILQ_HEAD_INITIALIZER(audiodevlist);
 
+#define AUDIODEV_SAMPLE_RATE	44100
+
+static unsigned int
+audiodev_probe_pchans(struct audiodev *adev)
+{
+	audio_info_t info;
+	unsigned int nchans = 0, n;
+	int error;
+
+	AUDIO_INITINFO(info);
+	info.play.sample_rate = AUDIODEV_SAMPLE_RATE;
+	info.play.precision = 16;
+	info.play.encoding = AUDIO_ENCODING_SLINEAR_LE;
+	info.play.channels = 1;
+	info.mode = AUMODE_PLAY;
+	error = ioctl(adev-fd, AUDIO_SETINFO, info);
+	if (error == -1)
+		return 0;
+	nchans = 1;
+
+	for (n = 2; n = 16; n += 2) {
+		info.play.channels = n;
+		error = ioctl(adev-fd, AUDIO_SETINFO, info);
+		if (error == -1)
+			break;
+		nchans = info.play.channels;
+	}
+
+	return nchans;
+}
+
 static int
 audiodev_getinfo(struct audiodev *adev)
 {
@@ -64,6 +96,8 @@
 		return -1;
 	}
 
+	adev-pchan = audiodev_probe_pchans(adev);
+
 	return 0;
 }
 
@@ -107,7 +141,7 @@
 	struct audiodev *adev;
 	int fd, error;
 
-	fd = open(DRVCTLDEV, O_RDWR);
+	fd = open(DRVCTLDEV, O_RDONLY);
 	if (fd == -1) {
 		perror(open  DRVCTLDEV);
 		return -1;
@@ -202,3 +236,49 @@
 
 	return 0;
 }
+
+int
+audiodev_test(struct audiodev *adev, unsigned int chanmask)
+{
+	audio_info_t info;
+	int16_t *buf;
+	size_t buflen;
+	off_t off;
+
+	AUDIO_INITINFO(info);
+	info.play.sample_rate = AUDIODEV_SAMPLE_RATE;
+	info.play.channels = adev-pchan;
+	info.play.precision = 16;
+	info.play.encoding = AUDIO_ENCODING_SLINEAR_LE;
+	info.mode = AUMODE_PLAY;
+	if (ioctl(adev-fd, AUDIO_SETINFO, info) == -1) {
+		perror(ioctl AUDIO_SETINFO);
+		return -1;
+	}
+	if (ioctl(adev-fd, AUDIO_GETINFO, info) == -1) {
+		perror(ioctl AUDIO_GETINFO);
+		return -1;
+	}
+
+	dtmf_new(buf, buflen, info.play.sample_rate, 2,
+	adev-pchan, chanmask, 350.0, 440.0);
+	if (buf == NULL)
+		return -1;
+
+	off = 0;
+	while (buflen  0) {
+		size_t wlen = info.play.buffer_size;
+		if (wlen  buflen)
+			wlen = buflen;
+		write(adev-fd, (char *)buf + off, wlen);
+		off += wlen;
+		buflen -= wlen;
+	}
+
+	if (ioctl(adev-fd, AUDIO_DRAIN) == -1)
+		perror(ioctl AUDIO_DRAIN);
+
+	free(buf);
+
+	return 0;
+}
Index: src/usr.bin/audiocfg/audiodev.h
diff -u src/usr.bin/audiocfg/audiodev.h:1.1.1.1 src/usr.bin/audiocfg/audiodev.h:1.2
--- src/usr.bin/audiocfg/audiodev.h:1.1.1.1	Mon Aug 30 02:19:47 2010
+++ src/usr.bin/audiocfg/audiodev.h	Wed Sep  1 09:04:16 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: audiodev.h,v 1.1.1.1 2010/08/30 02:19:47 mrg Exp $ */
+/* $NetBSD: audiodev.h,v 1.2 2010/09/01 09:04:16 jmcneill Exp $ */
 
 /*
  * Copyright (c) 2010 Jared D. McNeill jmcne...@invisible.ca
@@ -44,6 +44,8 @@
 	dev_t dev;
 	bool defaultdev;
 
+	int pchan;
+
 	audio_device_t audio_device;
 
 	TAILQ_ENTRY(audiodev) next;
@@ 

CVS commit: src/usr.bin/audiocfg

2010-09-01 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Wed Sep  1 09:17:31 UTC 2010

Modified Files:
src/usr.bin/audiocfg: audiocfg.1

Log Message:
Update for Jared's changes from a few minutes ago.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/audiocfg/audiocfg.1

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/audiocfg/audiocfg.1
diff -u src/usr.bin/audiocfg/audiocfg.1:1.2 src/usr.bin/audiocfg/audiocfg.1:1.3
--- src/usr.bin/audiocfg/audiocfg.1:1.2	Wed Sep  1 07:50:33 2010
+++ src/usr.bin/audiocfg/audiocfg.1	Wed Sep  1 09:17:31 2010
@@ -1,4 +1,4 @@
-.\	$NetBSD: audiocfg.1,v 1.2 2010/09/01 07:50:33 wiz Exp $
+.\	$NetBSD: audiocfg.1,v 1.3 2010/09/01 09:17:31 wiz Exp $
 .\
 .\ Copyright (c) 2010 The NetBSD Foundation, Inc.
 .\ All rights reserved.
@@ -35,23 +35,38 @@
 .Nd configure default audio device
 .Sh SYNOPSIS
 .Nm
-.Op index
+.Cm list
+.Nm
+.Cm default
+.Ar index
+.Nm
+.Cm test
+.Ar index
 .Sh DESCRIPTION
 The
 .Nm
 utility helps maintaining the audio and mixer device symlinks.
-Run without arguments, it lists the available audio devices and shows
-the currently selected default audio device.
-If given an
-.Ar index
-argument, that device is set as default audio device.
+.Pp
+Run with
+.Dq Cm list ,
+it lists the available audio devices and shows the currently selected
+default audio device.
+Called with
+.Dq Cm test ,
+it plays a tone of 2 seconds for each channel of the device with the index
+.Ar index .
+Called with
+.Dq Cm default ,
+it sets the default audio device to the one with the index
+.Ar index .
+.Pp
 .Nm
 needs access to
 .Pa /dev/drvctl
 and write access to
 .Pa /dev
-(when given an
-.Ar index )
+(when used with
+.Dq Cm default )
 to work.
 .Sh FILES
 .Bl -tag -width 10n
@@ -64,7 +79,7 @@
 .It Pa /dev/audioctl[0-9]*
 Available audio control devices.
 .It Pa /dev/drvctl
-Used for finding the correlating audio driver to an audio device.
+Used for finding the corresponding audio driver to an audio device.
 .It Pa /dev/mixer
 Symlink to default mixer device.
 .It Pa /dev/mixer[0-9]*



CVS commit: src/usr.bin/audiocfg

2010-09-01 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Wed Sep  1 09:18:04 UTC 2010

Modified Files:
src/usr.bin/audiocfg: main.c

Log Message:
Index argument is not optional, make it clearer in the usage.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/audiocfg/main.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/audiocfg/main.c
diff -u src/usr.bin/audiocfg/main.c:1.2 src/usr.bin/audiocfg/main.c:1.3
--- src/usr.bin/audiocfg/main.c:1.2	Wed Sep  1 09:04:16 2010
+++ src/usr.bin/audiocfg/main.c	Wed Sep  1 09:18:03 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.2 2010/09/01 09:04:16 jmcneill Exp $ */
+/* $NetBSD: main.c,v 1.3 2010/09/01 09:18:03 wiz Exp $ */
 
 /*
  * Copyright (c) 2010 Jared D. McNeill jmcne...@invisible.ca
@@ -40,8 +40,8 @@
 usage(const char *p)
 {
 	fprintf(stderr, usage: %s list\n, p);
-	fprintf(stderr,%s default [index]\n, p);
-	fprintf(stderr,%s test [index]\n, p);
+	fprintf(stderr,%s default index\n, p);
+	fprintf(stderr,%s test index\n, p);
 	exit(EXIT_FAILURE);
 }
 



CVS commit: src/usr.bin/audiocfg

2010-09-01 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Wed Sep  1 21:54:00 UTC 2010

Modified Files:
src/usr.bin/audiocfg: dtmf.c

Log Message:
use htole16 to ensure that the pcm stream is slinear16_le on big endian hosts


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/audiocfg/dtmf.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/audiocfg/dtmf.c
diff -u src/usr.bin/audiocfg/dtmf.c:1.1 src/usr.bin/audiocfg/dtmf.c:1.2
--- src/usr.bin/audiocfg/dtmf.c:1.1	Wed Sep  1 09:04:16 2010
+++ src/usr.bin/audiocfg/dtmf.c	Wed Sep  1 21:54:00 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: dtmf.c,v 1.1 2010/09/01 09:04:16 jmcneill Exp $ */
+/* $NetBSD: dtmf.c,v 1.2 2010/09/01 21:54:00 jmcneill Exp $ */
 
 /*
  * Copyright (c) 2010 Jared D. McNeill jmcne...@invisible.ca
@@ -26,6 +26,8 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
+#include sys/endian.h
+
 #include fcntl.h
 #include math.h
 #include stdio.h
@@ -50,9 +52,10 @@
 		for (c = 0; c  channels; c++) {
 			if ((chanmask  (1  c)) == 0)
 continue;
-			buf[c] = 
+			buf[c] = htole16(
 			(sin(i * PI2 * (freq1 / sample_rate)) +
-			 sin(i * PI2 * (freq2 / sample_rate))) * 16383;
+			 sin(i * PI2 * (freq2 / sample_rate))) * 16383
+	);
 		}
 		buf += channels;
 	}



CVS commit: src/usr.bin/audiocfg

2010-09-01 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Thu Sep  2 02:08:30 UTC 2010

Modified Files:
src/usr.bin/audiocfg: main.c

Log Message:
print the version field from AUDIO_GETDEV if present


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/audiocfg/main.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/audiocfg/main.c
diff -u src/usr.bin/audiocfg/main.c:1.3 src/usr.bin/audiocfg/main.c:1.4
--- src/usr.bin/audiocfg/main.c:1.3	Wed Sep  1 09:18:03 2010
+++ src/usr.bin/audiocfg/main.c	Thu Sep  2 02:08:30 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.3 2010/09/01 09:18:03 wiz Exp $ */
+/* $NetBSD: main.c,v 1.4 2010/09/02 02:08:30 jmcneill Exp $ */
 
 /*
  * Copyright (c) 2010 Jared D. McNeill jmcne...@invisible.ca
@@ -62,9 +62,12 @@
 		n = audiodev_count();
 		for (i = 0; i  n; i++) {
 			adev = audiodev_get(i);
-			printf(%u: [%c] %s: %s (%u playback channel%s)\n,
-			i, adev-defaultdev ? '*' : ' ',
-			adev-xname, adev-audio_device.name,
+			printf(%u: [%c] %s: ,
+			i, adev-defaultdev ? '*' : ' ', adev-xname);
+			printf(%s, adev-audio_device.name);
+			if (strlen(adev-audio_device.version)  0)
+printf( %s, adev-audio_device.version);
+			printf(, %u playback channel%s\n,
 			adev-pchan, adev-pchan == 1 ?  : s);
 		}
 	} else if (strcmp(argv[1], default) == 0  argc == 3) {



CVS commit: src/usr.bin/audiocfg

2010-08-31 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Tue Aug 31 14:57:26 UTC 2010

Modified Files:
src/usr.bin/audiocfg: Makefile
Added Files:
src/usr.bin/audiocfg: audiocfg.1

Log Message:
Add man page.


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.1 -r1.2 src/usr.bin/audiocfg/Makefile
cvs rdiff -u -r0 -r1.1 src/usr.bin/audiocfg/audiocfg.1

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/audiocfg/Makefile
diff -u src/usr.bin/audiocfg/Makefile:1.1.1.1 src/usr.bin/audiocfg/Makefile:1.2
--- src/usr.bin/audiocfg/Makefile:1.1.1.1	Mon Aug 30 02:19:47 2010
+++ src/usr.bin/audiocfg/Makefile	Tue Aug 31 14:57:26 2010
@@ -1,7 +1,6 @@
 PROG=	audiocfg
 SRCS=	audiodev.c drvctl.c
 SRCS+=	main.c
-NOMAN=	# defined
 WARNS=	3
 
 LDADD+=	-lprop

Added files:

Index: src/usr.bin/audiocfg/audiocfg.1
diff -u /dev/null src/usr.bin/audiocfg/audiocfg.1:1.1
--- /dev/null	Tue Aug 31 14:57:26 2010
+++ src/usr.bin/audiocfg/audiocfg.1	Tue Aug 31 14:57:26 2010
@@ -0,0 +1,71 @@
+.\	$NetBSD: audiocfg.1,v 1.1 2010/08/31 14:57:26 wiz Exp $
+.\
+.\ Copyright (c) 2010 The NetBSD Foundation, Inc.
+.\ All rights reserved.
+.\
+.\ This code is derived from software contributed to The NetBSD Foundation
+.\ by Thomas Klausner.
+.\
+.\ Redistribution and use in source and binary forms, with or without
+.\ modification, are permitted provided that the following conditions
+.\ are met:
+.\ 1. Redistributions of source code must retain the above copyright
+.\notice, this list of conditions and the following disclaimer.
+.\ 2. Redistributions in binary form must reproduce the above copyright
+.\notice, this list of conditions and the following disclaimer in the
+.\documentation and/or other materials provided with the distribution.
+.\
+.\ THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+.\ ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+.\ TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+.\ PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+.\ BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+.\ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+.\ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+.\ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+.\ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+.\ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+.\ POSSIBILITY OF SUCH DAMAGE.
+.\
+.Dd August 31, 2010
+.Dt AUDIOCFG 1
+.Os
+.Sh NAME
+.Nm audiocfg
+.Nd configure default audio device
+.Sh SYNOPSIS
+.Nm
+.Op index
+.Sh DESCRIPTION
+The
+.Nm
+utility helps maintaining a
+.Pa /dev/audio
+symlink.
+Run without arguments, it lists the available audio devices and shows
+the current default audio device.
+If given an
+.Ar index
+argument, that device is set as default audio device.
+.Nm
+needs access to
+.Pa /dev/drvctl
+and write access to
+.Pa /dev
+(when given an
+.Ar index )
+to work.
+.Sh FILES
+.Bl -tag -width 10n
+.It Pa /dev/audio
+Symlink to default audio device.
+.It Pa /dev/audio[0-9]*
+Available audio devices.
+.It Pa /dev/drvctl
+Used for finding the correlating audio driver to an audio device.
+.El
+.Sh SEE ALSO
+.Xr audioplay 1 ,
+.Xr audiorecord 1 ,
+.Xr audio 4 ,
+.Xr drvctl 8



CVS commit: src/usr.bin/audiocfg

2010-08-29 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Mon Aug 30 02:19:47 UTC 2010

Update of /cvsroot/src/usr.bin/audiocfg
In directory ivanova.netbsd.org:/tmp/cvs-serv10110

Log Message:
add a simple app to maintain the symlinks for audio devices in /dev, so
that it's easy to change the default audio device.  eg:

# audiocfg
0: [*] audio0: HD Audio
1: [ ] audio1: HD Audio
2: [ ] audio2: Pseudo Audio
# audiocfg 1
setting default audio device to audio1
# audiocfg
0: [ ] audio0: HD Audio
1: [*] audio1: HD Audio
2: [ ] audio2: Pseudo Audio

written by jared.  thanks!

(there's a separate patch in the works to give HD Audio a better name.)


this is not enabled yet, but will be soon.

it also needs a manual page.  any takers?

Status:

Vendor Tag: jmcneill
Release Tags:   audiocfg1

N src/usr.bin/audiocfg/audiodev.h
N src/usr.bin/audiocfg/Makefile
N src/usr.bin/audiocfg/drvctl.c
N src/usr.bin/audiocfg/drvctl.h
N src/usr.bin/audiocfg/main.c
N src/usr.bin/audiocfg/audiodev.c

No conflicts created by this import