Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F85412646
D45501 test
No One
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Authored By
christos
Jun 5 2024, 6:39 PM
2024-06-05 18:39:52 (UTC+0)
Size
4 KB
Referenced Files
None
Subscribers
None
D45501 test
View Options
#include <sys/sndstat.h>
#include <sys/nv.h>
#include <err.h>
#include <fcntl.h>
#include <stdlib.h>
#include <unistd.h>
int
main(int argc, char *argv[])
{
nvlist_t *nvl;
const nvlist_t * const *di;
struct sndstioc_nv_arg arg;
size_t nitems;
int fd;
int pchan, rchan, pvchan, rvchan, chans;
if ((fd = open("/dev/sndstat", O_RDONLY)) < 0)
err(1, "open");
if (ioctl(fd, SNDSTIOC_REFRESH_DEVS, NULL) < 0)
err(1, "ioctl(SNDSTIOC_REFRESH_DEVS)");
arg.nbytes = 0;
arg.buf = NULL;
if (ioctl(fd, SNDSTIOC_GET_DEVS, &arg) < 0)
err(1, "(1) ioctl(SNDSTIOC_GET_DEVS)");
if ((arg.buf = malloc(arg.nbytes)) == NULL)
err(1, "malloc");
if (ioctl(fd, SNDSTIOC_GET_DEVS, &arg) < 0)
err(1, "(2) ioctl(SNDSTIOC_GET_DEVS)");
nvl = nvlist_unpack(arg.buf, arg.nbytes, 0);
free(arg.buf);
di = nvlist_get_nvlist_array(nvl, SNDST_DSPS, &nitems);
for (size_t i = 0; i < nitems; i++) {
const nvlist_t * const *cdi;
size_t nchans;
printf("----\n");
printf("from_user=%d\n", nvlist_get_bool(di[i],
SNDST_DSPS_FROM_USER));
printf("nameunit=%s\n", nvlist_get_string(di[i],
SNDST_DSPS_NAMEUNIT));
pchan = nvlist_get_number(di[i], SNDST_DSPS_PCHAN);
rchan = nvlist_get_number(di[i], SNDST_DSPS_RCHAN);
printf("pchan=%d\n", pchan);
printf("rchan=%d\n", rchan);
if (!nvlist_exists(di[i], SNDST_DSPS_PROVIDER_INFO))
continue;
pvchan = nvlist_get_number(
nvlist_get_nvlist(di[i], SNDST_DSPS_PROVIDER_INFO),
SNDST_DSPS_SOUND4_PVCHAN);
rvchan = nvlist_get_number(
nvlist_get_nvlist(di[i], SNDST_DSPS_PROVIDER_INFO),
SNDST_DSPS_SOUND4_RVCHAN);
chans = pchan + rchan + pvchan + rvchan;
printf("pvchan=%d\n", pvchan);
printf("rvchan=%d\n", rvchan);
printf("chans=%d\n", chans);
cdi = nvlist_get_nvlist_array(
nvlist_get_nvlist(di[i], SNDST_DSPS_PROVIDER_INFO),
SNDST_DSPS_SOUND4_CHAN_INFO, &nchans);
for (size_t j = 0; j < nchans; j++) {
printf("======\n");
printf("name=%s\n", nvlist_get_string(cdi[j],
SNDST_DSPS_SOUND4_CHAN_NAME));
printf("parentchan=%s\n", nvlist_get_string(cdi[j],
SNDST_DSPS_SOUND4_CHAN_PARENTCHAN));
printf("unit=%d\n", (int)nvlist_get_number(cdi[j],
SNDST_DSPS_SOUND4_CHAN_UNIT));
printf("latency=%d\n", (int)nvlist_get_number(cdi[j],
SNDST_DSPS_SOUND4_CHAN_LATENCY));
printf("rate=%d\n", (int)nvlist_get_number(cdi[j],
SNDST_DSPS_SOUND4_CHAN_RATE));
printf("format=0x%x\n", (int)nvlist_get_number(cdi[j],
SNDST_DSPS_SOUND4_CHAN_FORMAT));
printf("pid=%d\n", (int)nvlist_get_number(cdi[j],
SNDST_DSPS_SOUND4_CHAN_PID));
printf("comm=%s\n", nvlist_get_string(cdi[j],
SNDST_DSPS_SOUND4_CHAN_COMM));
printf("interrupts=%d\n", (int)nvlist_get_number(cdi[j],
SNDST_DSPS_SOUND4_CHAN_INTR));
printf("xruns=%d\n", (int)nvlist_get_number(cdi[j],
SNDST_DSPS_SOUND4_CHAN_XRUNS));
printf("feedcount=%d\n", (int)nvlist_get_number(cdi[j],
SNDST_DSPS_SOUND4_CHAN_FEEDCNT));
printf("leftvol=%d\n", (int)nvlist_get_number(cdi[j],
SNDST_DSPS_SOUND4_CHAN_LEFTVOL));
printf("rightvol=%d\n", (int)nvlist_get_number(cdi[j],
SNDST_DSPS_SOUND4_CHAN_RIGHTVOL));
printf("hwbuf_fmt=0x%x\n", (int)nvlist_get_number(cdi[j],
SNDST_DSPS_SOUND4_CHAN_HWBUF_FORMAT));
printf("hwbuf_size=%d\n", (int)nvlist_get_number(cdi[j],
SNDST_DSPS_SOUND4_CHAN_HWBUF_SIZE));
printf("hwbuf_blksz=%d\n", (int)nvlist_get_number(cdi[j],
SNDST_DSPS_SOUND4_CHAN_HWBUF_BLKSZ));
printf("hwbuf_blkcnt=%d\n", (int)nvlist_get_number(cdi[j],
SNDST_DSPS_SOUND4_CHAN_HWBUF_BLKCNT));
printf("hwbuf_free=%d\n", (int)nvlist_get_number(cdi[j],
SNDST_DSPS_SOUND4_CHAN_HWBUF_FREE));
printf("hwbuf_ready=%d\n", (int)nvlist_get_number(cdi[j],
SNDST_DSPS_SOUND4_CHAN_HWBUF_READY));
printf("swbuf_fmt=0x%x\n", (int)nvlist_get_number(cdi[j],
SNDST_DSPS_SOUND4_CHAN_SWBUF_FORMAT));
printf("swbuf_size=%d\n", (int)nvlist_get_number(cdi[j],
SNDST_DSPS_SOUND4_CHAN_SWBUF_SIZE));
printf("swbuf_blksz=%d\n", (int)nvlist_get_number(cdi[j],
SNDST_DSPS_SOUND4_CHAN_SWBUF_BLKSZ));
printf("swbuf_blkcnt=%d\n", (int)nvlist_get_number(cdi[j],
SNDST_DSPS_SOUND4_CHAN_SWBUF_BLKCNT));
printf("swbuf_free=%d\n", (int)nvlist_get_number(cdi[j],
SNDST_DSPS_SOUND4_CHAN_SWBUF_FREE));
printf("swbuf_ready=%d\n", (int)nvlist_get_number(cdi[j],
SNDST_DSPS_SOUND4_CHAN_SWBUF_READY));
printf("feederchain=%s\n", nvlist_get_string(cdi[j],
SNDST_DSPS_SOUND4_CHAN_FEEDERCHAIN));
}
}
nvlist_destroy(nvl);
return (0);
}
File Metadata
Details
Attached
Mime Type
text/plain; charset=utf-8
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
9851530
Default Alt Text
D45501 test (4 KB)
Attached To
Mode
P638 D45501 test
Attached
Detach File
Event Timeline
Log In to Comment