summaryrefslogtreecommitdiff
path: root/sys/dev/audio/audio.c
diff options
context:
space:
mode:
authorisaki <isaki@NetBSD.org>2020-04-29 03:58:27 +0000
committerisaki <isaki@NetBSD.org>2020-04-29 03:58:27 +0000
commit12fe30132aa8bc4eebf04e103ebfa9da768d0feb (patch)
treed2c00a1e16ef1ff33b836dcc6e09d972845f3cad /sys/dev/audio/audio.c
parent9107cf7480fdc902e9b30f86cf2db089eb70eb73 (diff)
Set AUDIO_BLK_MS 40 msec on other old(slow) architectures not only m68k.
Thanks tsutsui@ for comment about architecture choice. And move it from audiodef.h to audio.c as suggested by joerg@.
Diffstat (limited to 'sys/dev/audio/audio.c')
-rw-r--r--sys/dev/audio/audio.c39
1 files changed, 37 insertions, 2 deletions
diff --git a/sys/dev/audio/audio.c b/sys/dev/audio/audio.c
index 4dadec12e48..32a6e7ac114 100644
--- a/sys/dev/audio/audio.c
+++ b/sys/dev/audio/audio.c
@@ -1,4 +1,4 @@
-/* $NetBSD: audio.c,v 1.67 2020/04/19 03:52:22 isaki Exp $ */
+/* $NetBSD: audio.c,v 1.68 2020/04/29 03:58:27 isaki Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -138,7 +138,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.67 2020/04/19 03:52:22 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.68 2020/04/29 03:58:27 isaki Exp $");
#ifdef _KERNEL_OPT
#include "audio.h"
@@ -451,6 +451,41 @@ audio_track_bufstat(audio_track_t *track, struct audio_track_debugbuf *buf)
#define SPECIFIED(x) ((x) != ~0)
#define SPECIFIED_CH(x) ((x) != (u_char)~0)
+/*
+ * Default hardware blocksize in msec.
+ *
+ * We use 10 msec for most platforms. This period is good enough to play
+ * audio and video synchronizely.
+ * In contrast, for very old platforms, this is usually too short and too
+ * severe. Also such platforms usually can not play video confortably, so
+ * it's not so important to make the blocksize shorter.
+ * In either case, you can overwrite AUDIO_BLK_MS by your kernel
+ * configuration file if you wish.
+ *
+ * 40 msec was initially choosen for the following reason:
+ * (1 / 40ms) = 25 = 5^2. Thus, the frequency is factored by 5.
+ * In this case, the number of frames in a block can be an integer
+ * even if the frequency is a multiple of 100 (44100, 48000, etc),
+ * or even if 15625Hz (vs(4)).
+ */
+#if defined(__hppa__) || \
+ defined(__m68k__) || \
+ defined(__sh3__) || \
+ (defined(__sparc__) && !defined(__sparc64__)) || \
+ defined(__vax__)
+#define AUDIO_TOO_SLOW_ARCHS 1
+#endif
+
+#if !defined(AUDIO_BLK_MS)
+# if defined(AUDIO_TOO_SLOW_ARCHS)
+# define AUDIO_BLK_MS 40
+# else
+# define AUDIO_BLK_MS 10
+# endif
+#endif
+
+#undef AUDIO_TOO_SLOW_ARCHS
+
/* Device timeout in msec */
#define AUDIO_TIMEOUT (3000)