Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/audiocfg Use device unit number for index.
details: https://anonhg.NetBSD.org/src/rev/c53fad47bb02
branches: trunk
changeset: 453722:c53fad47bb02
user: isaki <isaki%NetBSD.org@localhost>
date: Sat Aug 24 05:45:24 2019 +0000
description:
Use device unit number for index.
The index number was too confusing such as
0: [ ] audio1 @ wss0
1: [*] audio0 @ yds0
in my PC for example. Here is new format:
[*] audio0 @ yds0
[ ] audio1 @ wss0
In this style, devices are always listed in order of unit number
and 0 always means audio0, 1 always means audio1.
diffstat:
usr.bin/audiocfg/audiodev.c | 25 +++++++++++--------------
usr.bin/audiocfg/audiodev.h | 4 ++--
usr.bin/audiocfg/main.c | 21 ++++++++++++---------
3 files changed, 25 insertions(+), 25 deletions(-)
diffs (143 lines):
diff -r f02624068983 -r c53fad47bb02 usr.bin/audiocfg/audiodev.c
--- a/usr.bin/audiocfg/audiodev.c Sat Aug 24 04:04:10 2019 +0000
+++ b/usr.bin/audiocfg/audiodev.c Sat Aug 24 05:45:24 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: audiodev.c,v 1.9 2019/08/24 04:04:10 isaki Exp $ */
+/* $NetBSD: audiodev.c,v 1.10 2019/08/24 05:45:24 isaki Exp $ */
/*
* Copyright (c) 2010 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -48,6 +48,7 @@
static TAILQ_HEAD(audiodevhead, audiodev) audiodevlist =
TAILQ_HEAD_INITIALIZER(audiodevlist);
+static unsigned int maxunit;
#define AUDIODEV_SAMPLE_RATE 44100
@@ -138,6 +139,9 @@
TAILQ_INSERT_TAIL(&audiodevlist, adev, next);
+ if (unit > maxunit)
+ maxunit = unit;
+
return 0;
}
@@ -179,29 +183,22 @@
}
unsigned int
-audiodev_count(void)
+audiodev_maxunit(void)
{
- struct audiodev *adev;
- unsigned int n;
-
- n = 0;
- TAILQ_FOREACH(adev, &audiodevlist, next)
- ++n;
-
- return n;
+ return maxunit;
}
+/*
+ * Get audiodev corresponding to audio<i> device.
+ */
struct audiodev *
audiodev_get(unsigned int i)
{
struct audiodev *adev;
- unsigned int n;
- n = 0;
TAILQ_FOREACH(adev, &audiodevlist, next) {
- if (n == i)
+ if (i == adev->unit)
return adev;
- ++n;
}
return NULL;
diff -r f02624068983 -r c53fad47bb02 usr.bin/audiocfg/audiodev.h
--- a/usr.bin/audiocfg/audiodev.h Sat Aug 24 04:04:10 2019 +0000
+++ b/usr.bin/audiocfg/audiodev.h Sat Aug 24 05:45:24 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: audiodev.h,v 1.7 2019/08/24 04:04:10 isaki Exp $ */
+/* $NetBSD: audiodev.h,v 1.8 2019/08/24 05:45:25 isaki Exp $ */
/*
* Copyright (c) 2010 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -60,7 +60,7 @@
};
int audiodev_refresh(void);
-unsigned int audiodev_count(void);
+unsigned int audiodev_maxunit(void);
struct audiodev * audiodev_get(unsigned int);
int audiodev_set_default(struct audiodev *);
int audiodev_set_param(struct audiodev *, int,
diff -r f02624068983 -r c53fad47bb02 usr.bin/audiocfg/main.c
--- a/usr.bin/audiocfg/main.c Sat Aug 24 04:04:10 2019 +0000
+++ b/usr.bin/audiocfg/main.c Sat Aug 24 05:45:24 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.11 2019/08/24 04:04:10 isaki Exp $ */
+/* $NetBSD: main.c,v 1.12 2019/08/24 05:45:25 isaki Exp $ */
/*
* Copyright (c) 2010 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -72,15 +72,15 @@
u_int encoding_max = __arraycount(encoding_names);
static void
-print_audiodev(struct audiodev *adev, int i)
+print_audiodev(struct audiodev *adev)
{
struct audiofmt *f;
int j;
assert(adev != NULL);
- printf("%u: [%c] %s @ %s: ",
- i, adev->defaultdev ? '*' : ' ',
+ printf("[%c] %s @ %s: ",
+ adev->defaultdev ? '*' : ' ',
adev->xname, adev->pxname);
printf("%s", adev->audio_device.name);
if (strlen(adev->audio_device.version) > 0)
@@ -159,9 +159,12 @@
/* NOTREACHED */
if (strcmp(argv[1], "list") == 0 && argc == 2) {
- n = audiodev_count();
- for (i = 0; i < n; i++)
- print_audiodev(audiodev_get(i), i);
+ n = audiodev_maxunit();
+ for (i = 0; i <= n; i++) {
+ adev = audiodev_get(i);
+ if (adev)
+ print_audiodev(adev);
+ }
} else if (strcmp(argv[1], "list") == 0 && argc == 3) {
errno = 0;
i = strtoul(argv[2], NULL, 10);
@@ -173,7 +176,7 @@
fprintf(stderr, "no such device\n");
return EXIT_FAILURE;
}
- print_audiodev(adev, i);
+ print_audiodev(adev);
} else if (strcmp(argv[1], "default") == 0 && argc == 3) {
if (*argv[2] < '0' || *argv[2] > '9')
usage(argv[0]);
@@ -252,7 +255,7 @@
fprintf(stderr, "no such device\n");
return EXIT_FAILURE;
}
- print_audiodev(adev, i);
+ print_audiodev(adev);
if (audiodev_test(adev) == -1)
return EXIT_FAILURE;
} else
Home |
Main Index |
Thread Index |
Old Index