Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/fstat Support audio descriptor for fstat(1).
details: https://anonhg.NetBSD.org/src/rev/5dc262d696d2
branches: trunk
changeset: 1014150:5dc262d696d2
user: isaki <isaki%NetBSD.org@localhost>
date: Sun Sep 13 04:14:48 2020 +0000
description:
Support audio descriptor for fstat(1).
sys/dev/audio/*.h: export only what we need for fstat.
diffstat:
sys/dev/audio/audio_if.h | 6 ++++-
sys/dev/audio/audiodef.h | 15 +++++++++++--
usr.bin/fstat/misc.c | 50 ++++++++++++++++++++++++++++++++++++++++++++---
3 files changed, 63 insertions(+), 8 deletions(-)
diffs (167 lines):
diff -r 2c968daa6199 -r 5dc262d696d2 sys/dev/audio/audio_if.h
--- a/sys/dev/audio/audio_if.h Sun Sep 13 03:43:16 2020 +0000
+++ b/sys/dev/audio/audio_if.h Sun Sep 13 04:14:48 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: audio_if.h,v 1.2 2019/05/08 13:40:17 isaki Exp $ */
+/* $NetBSD: audio_if.h,v 1.3 2020/09/13 04:14:48 isaki Exp $ */
/*
* Copyright (c) 1994 Havard Eidnes.
@@ -57,6 +57,8 @@
struct audio_softc;
+#if defined(_KERNEL)
+
/**
* audio stream format
*/
@@ -154,6 +156,8 @@
const audio_params_t *);
extern const char *audio_encoding_name(int);
+#endif /* _KERNEL */
+
/* Device identity flags */
#define SOUND_DEVICE 0
#define AUDIO_DEVICE 0x80
diff -r 2c968daa6199 -r 5dc262d696d2 sys/dev/audio/audiodef.h
--- a/sys/dev/audio/audiodef.h Sun Sep 13 03:43:16 2020 +0000
+++ b/sys/dev/audio/audiodef.h Sun Sep 13 04:14:48 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: audiodef.h,v 1.14 2020/04/29 03:58:27 isaki Exp $ */
+/* $NetBSD: audiodef.h,v 1.15 2020/09/13 04:14:48 isaki Exp $ */
/*
* Copyright (C) 2017 Tetsuya Isaki. All rights reserved.
@@ -78,6 +78,8 @@
#define AUDIO_SCALEDOWN(value, bits) ((value) / (1 << (bits)))
#endif
+#if defined(_KERNEL)
+
/* conversion stage */
typedef struct {
audio_ring_t srcbuf;
@@ -92,7 +94,7 @@
AUDIO_STATE_DRAINING, /* now draining */
} audio_state_t;
-typedef struct audio_track {
+struct audio_track {
/*
* AUMODE_PLAY for playback track, or
* AUMODE_RECORD for recoding track.
@@ -167,7 +169,10 @@
volatile uint lock;
int id; /* track id for debug */
-} audio_track_t;
+};
+#endif /* _KERNEL */
+
+typedef struct audio_track audio_track_t;
struct audio_file {
struct audio_softc *sc;
@@ -197,6 +202,8 @@
SLIST_ENTRY(audio_file) entry;
};
+#if defined(_KERNEL)
+
struct audio_trackmixer {
struct audio_softc *sc;
@@ -439,4 +446,6 @@
}
}
+#endif /* _KERNEL */
+
#endif /* !_SYS_DEV_AUDIO_AUDIODEF_H_ */
diff -r 2c968daa6199 -r 5dc262d696d2 usr.bin/fstat/misc.c
--- a/usr.bin/fstat/misc.c Sun Sep 13 03:43:16 2020 +0000
+++ b/usr.bin/fstat/misc.c Sun Sep 13 04:14:48 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: misc.c,v 1.23 2020/05/02 18:42:30 christos Exp $ */
+/* $NetBSD: misc.c,v 1.24 2020/09/13 04:14:48 isaki Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: misc.c,v 1.23 2020/05/02 18:42:30 christos Exp $");
+__RCSID("$NetBSD: misc.c,v 1.24 2020/09/13 04:14:48 isaki Exp $");
#include <stdbool.h>
#include <sys/param.h>
@@ -60,6 +60,9 @@
#include <net/bpfdesc.h>
+#include <dev/audio/audiodef.h>
+#include <dev/audio/audio_if.h>
+
#include <err.h>
#include <util.h>
#include <string.h>
@@ -220,6 +223,46 @@
return 0;
}
+static int
+p_audio(struct file *f)
+{
+ struct audio_file af;
+ const char *devname;
+ const char *modename;
+
+ if (!KVM_READ(f->f_data, &af, sizeof(af))) {
+ dprintf("can't read audio_file at %p for pid %d",
+ f->f_data, Pid);
+ return 0;
+ }
+
+ if (ISDEVAUDIO(af.dev)) {
+ devname = "audio";
+ } else if (ISDEVSOUND(af.dev)) {
+ devname = "sound";
+ } else if (ISDEVAUDIOCTL(af.dev)) {
+ devname = "audioctl";
+ } else if (ISDEVMIXER(af.dev)) {
+ devname = "mixer";
+ } else {
+ devname = "???";
+ }
+
+ if (af.ptrack && af.rtrack) {
+ modename = "playback, record";
+ } else if (af.ptrack) {
+ modename = "playback";
+ } else if (af.rtrack) {
+ modename = "record";
+ } else {
+ modename = "-";
+ }
+
+ (void)printf("* audio@%s%d %s", devname, AUDIOUNIT(af.dev), modename);
+ oprint(f, "\n");
+ return 0;
+}
+
int
pmisc(struct file *f, const char *name)
{
@@ -263,8 +306,7 @@
printf("* crypto %p", f->f_data);
break;
case NL_AUDIO:
- printf("* audio %p", f->f_data);
- break;
+ return p_audio(f);
case NL_PAD:
printf("* pad %p", f->f_data);
break;
Home |
Main Index |
Thread Index |
Old Index