Module Name:    src
Committed By:   isaki
Date:           Sat Aug 24 03:28:38 UTC 2019

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

Log Message:
Rename some members in adev for clarity.  No functional changes intended.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/usr.bin/audiocfg/audiodev.c
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/audiocfg/audiodev.h
cvs rdiff -u -r1.9 -r1.10 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.7 src/usr.bin/audiocfg/audiodev.c:1.8
--- src/usr.bin/audiocfg/audiodev.c:1.7	Wed May  8 14:36:12 2019
+++ src/usr.bin/audiocfg/audiodev.c	Sat Aug 24 03:28:37 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: audiodev.c,v 1.7 2019/05/08 14:36:12 isaki Exp $ */
+/* $NetBSD: audiodev.c,v 1.8 2019/08/24 03:28:37 isaki Exp $ */
 
 /*
  * Copyright (c) 2010 Jared D. McNeill <jmcne...@invisible.ca>
@@ -63,26 +63,26 @@ audiodev_getinfo(struct audiodev *adev)
 	if (stat(_PATH_AUDIOCTL, &st) != -1 && st.st_rdev == adev->dev)
 		adev->defaultdev = true;
 
-	adev->fd = open(adev->ctlpath, O_RDONLY);
-	if (adev->fd == -1) {
+	adev->ctlfd = open(adev->ctlpath, O_RDONLY);
+	if (adev->ctlfd == -1) {
 			return -1;
 	}
-	if (ioctl(adev->fd, AUDIO_GETDEV, &adev->audio_device) == -1) {
-		close(adev->fd);
+	if (ioctl(adev->ctlfd, AUDIO_GETDEV, &adev->audio_device) == -1) {
+		close(adev->ctlfd);
 		return -1;
 	}
 
 	for (i = 0; ;i++) {
 		memset(&query, 0, sizeof(query));
 		query.index = i;
-		if (ioctl(adev->fd, AUDIO_QUERYFORMAT, &query) == -1) {
+		if (ioctl(adev->ctlfd, AUDIO_QUERYFORMAT, &query) == -1) {
 			if (errno == ENODEV) {
 				/* QUERYFORMAT not supported. */
 				break;
 			}
 			if (errno == EINVAL)
 				break;
-			close(adev->fd);
+			close(adev->ctlfd);
 			return -1;
 		}
 
@@ -91,8 +91,8 @@ audiodev_getinfo(struct audiodev *adev)
 		TAILQ_INSERT_TAIL(&adev->formats, f, next);
 	}
 
-	if (ioctl(adev->fd, AUDIO_GETFORMAT, &adev->info) == -1) {
-		close(adev->fd);
+	if (ioctl(adev->ctlfd, AUDIO_GETFORMAT, &adev->hwinfo) == -1) {
+		close(adev->ctlfd);
 		return -1;
 	}
 
@@ -158,8 +158,8 @@ audiodev_refresh(void)
 
 	while (!TAILQ_EMPTY(&audiodevlist)) {
 		adev = TAILQ_FIRST(&audiodevlist);
-		if (adev->fd != -1)
-			close(adev->fd);
+		if (adev->ctlfd != -1)
+			close(adev->ctlfd);
 		TAILQ_REMOVE(&audiodevlist, adev, next);
 		free(adev);
 	}
@@ -250,12 +250,12 @@ int
 audiodev_set_param(struct audiodev *adev, int mode,
 	const char *encname, unsigned int prec, unsigned int ch, unsigned int freq)
 {
-	struct audio_info ai;
+	audio_info_t ai;
 	int setmode;
 	u_int enc;
 
 	setmode = 0;
-	ai = adev->info;
+	ai = adev->hwinfo;
 
 	for (enc = 0; enc < encoding_max; enc++) {
 		if (strcmp(encname, encoding_names[enc]) == 0)
@@ -290,7 +290,7 @@ audiodev_set_param(struct audiodev *adev
 	ai.mode = setmode;
 	printf("setting %s to %s:%u, %uch, %uHz\n",
 	    adev->xname, encname, prec, ch, freq);
-	if (ioctl(adev->fd, AUDIO_SETFORMAT, &ai) == -1) {
+	if (ioctl(adev->ctlfd, AUDIO_SETFORMAT, &ai) == -1) {
 		perror("ioctl AUDIO_SETFORMAT");
 		return -1;
 	}
@@ -315,7 +315,7 @@ audiodev_test(struct audiodev *adev, uns
 
 	AUDIO_INITINFO(&info);
 	info.play.sample_rate = AUDIODEV_SAMPLE_RATE;
-	info.play.channels = adev->info.play.channels;
+	info.play.channels = adev->hwinfo.play.channels;
 	info.play.precision = 16;
 	info.play.encoding = AUDIO_ENCODING_SLINEAR_LE;
 	info.mode = AUMODE_PLAY;
@@ -329,7 +329,7 @@ audiodev_test(struct audiodev *adev, uns
 	}
 
 	dtmf_new(&buf, &buflen, info.play.sample_rate, 2,
-	    adev->info.play.channels, chanmask, 350.0, 440.0);
+	    adev->hwinfo.play.channels, chanmask, 350.0, 440.0);
 	if (buf == NULL) {
 		goto abort;
 	}

Index: src/usr.bin/audiocfg/audiodev.h
diff -u src/usr.bin/audiocfg/audiodev.h:1.5 src/usr.bin/audiocfg/audiodev.h:1.6
--- src/usr.bin/audiocfg/audiodev.h:1.5	Wed May  8 14:36:12 2019
+++ src/usr.bin/audiocfg/audiodev.h	Sat Aug 24 03:28:37 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: audiodev.h,v 1.5 2019/05/08 14:36:12 isaki Exp $ */
+/* $NetBSD: audiodev.h,v 1.6 2019/08/24 03:28:37 isaki Exp $ */
 
 /*
  * Copyright (c) 2010 Jared D. McNeill <jmcne...@invisible.ca>
@@ -46,14 +46,14 @@ struct audiodev {
 	uint16_t unit;
 	char path[PATH_MAX+1];
 	char ctlpath[PATH_MAX+1];
+	int ctlfd;
 
-	int fd;
 	dev_t dev;
 	bool defaultdev;
 
 	audio_device_t audio_device;
 	TAILQ_HEAD(, audiofmt) formats;
-	struct audio_info info;
+	audio_info_t hwinfo;
 
 	TAILQ_ENTRY(audiodev) next;
 };

Index: src/usr.bin/audiocfg/main.c
diff -u src/usr.bin/audiocfg/main.c:1.9 src/usr.bin/audiocfg/main.c:1.10
--- src/usr.bin/audiocfg/main.c:1.9	Thu Aug 22 14:40:14 2019
+++ src/usr.bin/audiocfg/main.c	Sat Aug 24 03:28:37 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.9 2019/08/22 14:40:14 isaki Exp $ */
+/* $NetBSD: main.c,v 1.10 2019/08/24 03:28:37 isaki Exp $ */
 
 /*
  * Copyright (c) 2010 Jared D. McNeill <jmcne...@invisible.ca>
@@ -87,17 +87,21 @@ print_audiodev(struct audiodev *adev, in
 		printf(" %s", adev->audio_device.version);
 	printf("\n");
 	printf("       playback: ");
-	if ((adev->info.mode & AUMODE_PLAY))
+	if ((adev->hwinfo.mode & AUMODE_PLAY)) {
 		printf("%uch, %uHz\n",
-		    adev->info.play.channels, adev->info.play.sample_rate);
-	else
+		    adev->hwinfo.play.channels,
+		    adev->hwinfo.play.sample_rate);
+	} else {
 		printf("unavailable\n");
+	}
 	printf("       record:   ");
-	if ((adev->info.mode & AUMODE_RECORD))
+	if ((adev->hwinfo.mode & AUMODE_RECORD)) {
 		printf("%uch, %uHz\n",
-		    adev->info.record.channels, adev->info.record.sample_rate);
-	else
+		    adev->hwinfo.record.channels,
+		    adev->hwinfo.record.sample_rate);
+	} else {
 		printf("unavailable\n");
+	}
 
 	TAILQ_FOREACH(f, &adev->formats, next) {
 		printf("       ");
@@ -249,7 +253,7 @@ main(int argc, char *argv[])
 			return EXIT_FAILURE;
 		}
 		print_audiodev(adev, i);
-		for (i = 0; i < adev->info.play.channels; i++) {
+		for (i = 0; i < adev->hwinfo.play.channels; i++) {
 			printf("  testing channel %d...", i);
 			fflush(stdout);
 			if (audiodev_test(adev, 1 << i) == -1)

Reply via email to