At Wed, 29 Apr 2020 12:22:01 +0900, Tetsuya Isaki wrote: > > i would just put it in types.h called __AUDIO_BLK_MS, > > and leave a default used in the code if unset. > It sounds nice. > I commit once here, and then I will try it.
How about this diff? The old platforms are the same as before, hppa, m68k, sh3, sparc(!64) and vax. Thanks, --- a/sys/arch/hppa/include/types.h +++ b/sys/arch/hppa/include/types.h @@ -103,4 +103,8 @@ extern const char __CONCAT(name,_ras_start[]), __CONCAT(name,_ras_end[]) #define __HAVE_MM_MD_DIRECT_MAPPED_PHYS #define __HAVE_MM_MD_KERNACC +#if defined(_KERNEL) +#define __AUDIO_BLK_MS (40) /* See sys/dev/audio/audio.c */ +#endif + #endif /* _HPPA_TYPES_H_ */ diff --git a/sys/arch/m68k/include/types.h b/sys/arch/m68k/include/types.h index d8b1347ae..0a581dff0 100644 --- a/sys/arch/m68k/include/types.h +++ b/sys/arch/m68k/include/types.h @@ -80,6 +80,7 @@ typedef int __register_t; #if defined(_KERNEL) #define __HAVE_RAS +#define __AUDIO_BLK_MS (40) /* See sys/dev/audio/audio.c */ #endif #endif /* !_M68K_TYPES_H_ */ diff --git a/sys/arch/sh3/include/types.h b/sys/arch/sh3/include/types.h index 9a8b247be..f0a8e92d7 100644 --- a/sys/arch/sh3/include/types.h +++ b/sys/arch/sh3/include/types.h @@ -79,6 +79,7 @@ typedef int __register_t; #if defined(_KERNEL) #define __HAVE_RAS +#define __AUDIO_BLK_MS (40) /* See sys/dev/audio/audio.c */ #endif #define __HAVE_CPU_LWP_SETPRIVATE diff --git a/sys/arch/sparc/include/types.h b/sys/arch/sparc/include/types.h index 01af19775..360bb069a 100644 --- a/sys/arch/sparc/include/types.h +++ b/sys/arch/sparc/include/types.h @@ -141,4 +141,10 @@ typedef unsigned long int __register_t; #define __HAVE_TLS_VARIANT_II #define __HAVE_COMMON___TLS_GET_ADDR +#if defined(_KERNEL) +#if !defined(__arch64__) +#define __AUDIO_BLK_MS (40) /* See sys/dev/audio/audio.c */ +#endif +#endif + #endif /* _MACHTYPES_H_ */ diff --git a/sys/arch/vax/include/types.h b/sys/arch/vax/include/types.h index e49c9db96..8ab482051 100644 --- a/sys/arch/vax/include/types.h +++ b/sys/arch/vax/include/types.h @@ -82,6 +82,7 @@ typedef int __register_t; #define __HAVE_OLD_DISKLABEL #ifdef _KERNEL #define __HAVE_RAS +#define __AUDIO_BLK_MS (40) /* See sys/dev/audio/audio.c */ #endif #define __HAVE___LWP_GETPRIVATE_FAST diff --git a/sys/dev/audio/audio.c b/sys/dev/audio/audio.c index 13386ccfb..20a0c6c10 100644 --- a/sys/dev/audio/audio.c +++ b/sys/dev/audio/audio.c @@ -183,6 +183,7 @@ __KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.41 2020/01/11 04:53:10 isaki Exp $"); #include <dev/audio/mulaw.h> #include <machine/endian.h> +#include <machine/types.h> /* for __AUDIO_BLK_MS */ #include <uvm/uvm.h> @@ -454,38 +455,25 @@ audio_track_bufstat(audio_track_t *track, struct audio_track_debugbuf *buf) /* * Default hardware blocksize in msec. * - * We use 10 msec for most platforms. This period is good enough to play - * audio and video synchronizely. + * We use 10 msec for most modern 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. + * it's not so important to make the blocksize shorter. If the platform + * defines its own value as __AUDIO_BLK_MS in its <machine/types.h>, it + * uses this instead. + * * 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 +# if defined(__AUDIO_BLK_MS) +# define AUDIO_BLK_MS __AUDIO_BLK_MS # else -# define AUDIO_BLK_MS 10 +# define AUDIO_BLK_MS (10) # endif #endif -#undef AUDIO_TOO_SLOW_ARCHS - /* Device timeout in msec */ #define AUDIO_TIMEOUT (3000) --- Tetsuya Isaki <is...@pastel-flower.jp / is...@netbsd.org>