at the request of mrg, print the parent of audioN's device name

This commit is contained in:
jmcneill 2010-09-02 02:17:35 +00:00
parent 59619cc632
commit e90b0e0082
5 changed files with 21 additions and 15 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: audiodev.c,v 1.2 2010/09/01 09:04:16 jmcneill Exp $ */
/* $NetBSD: audiodev.c,v 1.3 2010/09/02 02:17:35 jmcneill Exp $ */
/*
* Copyright (c) 2010 Jared D. McNeill <jmcneill@invisible.ca>
@ -102,7 +102,7 @@ audiodev_getinfo(struct audiodev *adev)
}
static int
audiodev_add(const char *dev, unsigned int unit)
audiodev_add(const char *pdev, const char *dev, unsigned int unit)
{
struct audiodev *adev;
@ -110,6 +110,7 @@ audiodev_add(const char *dev, unsigned int unit)
if (adev == NULL)
return -1;
strlcpy(adev->pxname, pdev, sizeof(adev->pxname));
strlcpy(adev->xname, dev, sizeof(adev->xname));
snprintf(adev->path, sizeof(adev->path) - 1, "/dev/%s", dev);
adev->unit = unit;
@ -130,9 +131,9 @@ audiodev_add(const char *dev, unsigned int unit)
}
static void
audiodev_cb(void *args, const char *dev, unsigned int unit)
audiodev_cb(void *args, const char *pdev, const char *dev, unsigned int unit)
{
audiodev_add(dev, unit);
audiodev_add(pdev, dev, unit);
}
int

View File

@ -1,4 +1,4 @@
/* $NetBSD: audiodev.h,v 1.2 2010/09/01 09:04:16 jmcneill Exp $ */
/* $NetBSD: audiodev.h,v 1.3 2010/09/02 02:17:35 jmcneill Exp $ */
/*
* Copyright (c) 2010 Jared D. McNeill <jmcneill@invisible.ca>
@ -36,7 +36,8 @@
#include <stdbool.h>
struct audiodev {
char xname[16];
char pxname[16]; /* hw (parent) device */
char xname[16]; /* audio(4) device */
uint16_t unit;
char path[PATH_MAX+1];

View File

@ -1,4 +1,4 @@
/* $NetBSD: drvctl.c,v 1.1.1.1 2010/08/30 02:19:47 mrg Exp $ */
/* $NetBSD: drvctl.c,v 1.2 2010/09/02 02:17:35 jmcneill Exp $ */
/*
* Copyright (c) 2010 Jared D. McNeill <jmcneill@invisible.ca>
@ -97,7 +97,8 @@ drvctl_get_properties(int fd, const char *devnode, prop_dictionary_t *props)
static int
drvctl_search(int fd, const char *curnode, const char *dvname,
void (*callback)(void *, const char *, unsigned int), void *args)
void (*callback)(void *, const char *, const char *, unsigned int),
void *args)
{
struct devlistargs laa;
unsigned int i;
@ -120,7 +121,8 @@ drvctl_search(int fd, const char *curnode, const char *dvname,
rv = prop_dictionary_get_uint32(props,
"device-unit", &unit);
if (rv == true)
callback(args, laa.l_childname[i], unit);
callback(args, curnode,
laa.l_childname[i], unit);
}
prop_object_release(props);
@ -134,7 +136,8 @@ drvctl_search(int fd, const char *curnode, const char *dvname,
int
drvctl_foreach(int fd, const char *dvname,
void (*callback)(void *, const char *, unsigned int), void *args)
void (*callback)(void *, const char *, const char *, unsigned int),
void *args)
{
return drvctl_search(fd, "", dvname, callback, args);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: drvctl.h,v 1.1.1.1 2010/08/30 02:19:47 mrg Exp $ */
/* $NetBSD: drvctl.h,v 1.2 2010/09/02 02:17:35 jmcneill Exp $ */
/*
* Copyright (c) 2010 Jared D. McNeill <jmcneill@invisible.ca>
@ -33,6 +33,6 @@
#include <sys/drvctlio.h>
int drvctl_foreach(int, const char *,
void (*)(void *, const char *, unsigned int), void *);
void (*)(void *, const char *, const char *, unsigned int), void *);
#endif /* !_HAVE_DRVCTL_H */

View File

@ -1,4 +1,4 @@
/* $NetBSD: main.c,v 1.4 2010/09/02 02:08:30 jmcneill Exp $ */
/* $NetBSD: main.c,v 1.5 2010/09/02 02:17:35 jmcneill Exp $ */
/*
* Copyright (c) 2010 Jared D. McNeill <jmcneill@invisible.ca>
@ -62,8 +62,9 @@ main(int argc, char *argv[])
n = audiodev_count();
for (i = 0; i < n; i++) {
adev = audiodev_get(i);
printf("%u: [%c] %s: ",
i, adev->defaultdev ? '*' : ' ', adev->xname);
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);