CVS commit: src/lib/libossaudio
Module Name:src Committed By: nia Date: Tue Jun 8 19:26:48 UTC 2021 Modified Files: src/lib/libossaudio: oss_dsp.c Log Message: ossaudio(3): nested switch statements are hard to read, refactor To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/lib/libossaudio/oss_dsp.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libossaudio/oss_dsp.c diff -u src/lib/libossaudio/oss_dsp.c:1.1 src/lib/libossaudio/oss_dsp.c:1.2 --- src/lib/libossaudio/oss_dsp.c:1.1 Tue Jun 8 18:43:54 2021 +++ src/lib/libossaudio/oss_dsp.c Tue Jun 8 19:26:48 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: oss_dsp.c,v 1.1 2021/06/08 18:43:54 nia Exp $ */ +/* $NetBSD: oss_dsp.c,v 1.2 2021/06/08 19:26:48 nia Exp $ */ /*- * Copyright (c) 1997-2021 The NetBSD Foundation, Inc. @@ -27,7 +27,7 @@ */ #include -__RCSID("$NetBSD: oss_dsp.c,v 1.1 2021/06/08 18:43:54 nia Exp $"); +__RCSID("$NetBSD: oss_dsp.c,v 1.2 2021/06/08 19:26:48 nia Exp $"); #include #include @@ -38,6 +38,9 @@ __RCSID("$NetBSD: oss_dsp.c,v 1.1 2021/0 (((info)->mode == AUMODE_RECORD) \ ? (info)->record.name : (info)->play.name) +static int encoding_to_format(u_int, u_int); +static int format_to_encoding(int, struct audio_info *); + static int get_vol(u_int, u_char); static void set_vol(int, int, bool); @@ -54,8 +57,6 @@ _oss_dsp_ioctl(int fd, unsigned long com struct count_info cntinfo; struct audio_encoding tmpenc; u_int u; - u_int encoding; - u_int precision; int perrors, rerrors; static int totalperrors = 0; static int totalrerrors = 0; @@ -173,82 +174,8 @@ _oss_dsp_ioctl(int fd, unsigned long com break; case SNDCTL_DSP_SETFMT: AUDIO_INITINFO(); - switch (INTARG) { - case AFMT_MU_LAW: - tmpinfo.play.precision = - tmpinfo.record.precision = 8; - tmpinfo.play.encoding = - tmpinfo.record.encoding = AUDIO_ENCODING_ULAW; - break; - case AFMT_A_LAW: - tmpinfo.play.precision = - tmpinfo.record.precision = 8; - tmpinfo.play.encoding = - tmpinfo.record.encoding = AUDIO_ENCODING_ALAW; - break; - case AFMT_U8: - tmpinfo.play.precision = - tmpinfo.record.precision = 8; - tmpinfo.play.encoding = - tmpinfo.record.encoding = AUDIO_ENCODING_ULINEAR; - break; - case AFMT_S8: - tmpinfo.play.precision = - tmpinfo.record.precision = 8; - tmpinfo.play.encoding = - tmpinfo.record.encoding = AUDIO_ENCODING_SLINEAR; - break; - case AFMT_S16_LE: - tmpinfo.play.precision = - tmpinfo.record.precision = 16; - tmpinfo.play.encoding = - tmpinfo.record.encoding = AUDIO_ENCODING_SLINEAR_LE; - break; - case AFMT_S16_BE: - tmpinfo.play.precision = - tmpinfo.record.precision = 16; - tmpinfo.play.encoding = - tmpinfo.record.encoding = AUDIO_ENCODING_SLINEAR_BE; - break; - case AFMT_U16_LE: - tmpinfo.play.precision = - tmpinfo.record.precision = 16; - tmpinfo.play.encoding = - tmpinfo.record.encoding = AUDIO_ENCODING_ULINEAR_LE; - break; - case AFMT_U16_BE: - tmpinfo.play.precision = - tmpinfo.record.precision = 16; - tmpinfo.play.encoding = - tmpinfo.record.encoding = AUDIO_ENCODING_ULINEAR_BE; - break; - /* - * XXX: When the kernel supports 24-bit LPCM by default, - * the 24-bit formats should be handled properly instead - * of falling back to 32 bits. - */ - case AFMT_S24_PACKED: - case AFMT_S24_LE: - case AFMT_S32_LE: - tmpinfo.play.precision = - tmpinfo.record.precision = 32; - tmpinfo.play.encoding = - tmpinfo.record.encoding = AUDIO_ENCODING_SLINEAR_LE; - break; - case AFMT_S24_BE: - case AFMT_S32_BE: - tmpinfo.play.precision = - tmpinfo.record.precision = 32; - tmpinfo.play.encoding = - tmpinfo.record.encoding = AUDIO_ENCODING_SLINEAR_BE; - break; - case AFMT_AC3: - tmpinfo.play.precision = - tmpinfo.record.precision = 16; - tmpinfo.play.encoding = - tmpinfo.record.encoding = AUDIO_ENCODING_AC3; - break; - default: + retval = format_to_encoding(INTARG, ); + if (retval < 0) { /* * OSSv4 specifies that if an invalid format is chosen * by an application then a sensible format supported @@ -270,7 +197,6 @@ _oss_dsp_ioctl(int fd, unsigned long com tmpinfo.record.precision = (tmpinfo.mode == AUMODE_RECORD) ? hwfmt.record.precision : hwfmt.play.precision ; - break; } /* * In the post-kernel-mixer world, assume that any error means @@ -284,55 +210,17 @@ _oss_dsp_ioctl(int fd, unsigned long com retval = ioctl(fd, AUDIO_GETBUFINFO, ); if (retval < 0) return retval; - encoding = GETPRINFO(, encoding); - precision = GETPRINFO(, precision); - switch (encoding) { - case AUDIO_ENCODING_ULAW: - idat = AFMT_MU_LAW; - break; - case AUDIO_ENCODING_ALAW: - idat = AFMT_A_LAW; - break; - case AUDIO_ENCODING_SLINEAR_LE: - if (precision == 32) -idat = AFMT_S32_LE; - else if (precision == 24) -idat = AFMT_S24_LE; - else if (precision ==
CVS commit: src/lib/libossaudio
Module Name:src Committed By: nia Date: Tue Jun 8 18:43:54 UTC 2021 Modified Files: src/lib/libossaudio: Makefile Added Files: src/lib/libossaudio: internal.h oss3_mixer.c oss4_global.c oss4_mixer.c oss_caps.c oss_dsp.c oss_ioctl.c Removed Files: src/lib/libossaudio: ossaudio.c Log Message: ossaudio(3): refactor library into separate files To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/lib/libossaudio/Makefile cvs rdiff -u -r0 -r1.1 src/lib/libossaudio/internal.h \ src/lib/libossaudio/oss3_mixer.c src/lib/libossaudio/oss4_global.c \ src/lib/libossaudio/oss4_mixer.c src/lib/libossaudio/oss_caps.c \ src/lib/libossaudio/oss_dsp.c src/lib/libossaudio/oss_ioctl.c cvs rdiff -u -r1.68 -r0 src/lib/libossaudio/ossaudio.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libossaudio/Makefile diff -u src/lib/libossaudio/Makefile:1.10 src/lib/libossaudio/Makefile:1.11 --- src/lib/libossaudio/Makefile:1.10 Sat May 5 15:57:45 2012 +++ src/lib/libossaudio/Makefile Tue Jun 8 18:43:54 2021 @@ -1,11 +1,13 @@ -# $NetBSD: Makefile,v 1.10 2012/05/05 15:57:45 christos Exp $ +# $NetBSD: Makefile,v 1.11 2021/06/08 18:43:54 nia Exp $ WARNS= 5 LIB= ossaudio MAN= ossaudio.3 -SRCS= ossaudio.c +SRCS= oss_caps.c oss_dsp.c oss_ioctl.c +SRCS+= oss3_mixer.c oss4_mixer.c +SRCS+= oss4_global.c CPPFLAGS+= -I${.CURDIR} Added files: Index: src/lib/libossaudio/internal.h diff -u /dev/null src/lib/libossaudio/internal.h:1.1 --- /dev/null Tue Jun 8 18:43:54 2021 +++ src/lib/libossaudio/internal.h Tue Jun 8 18:43:54 2021 @@ -0,0 +1,53 @@ +/* $NetBSD: internal.h,v 1.1 2021/06/08 18:43:54 nia Exp $ */ + +/*- + * Copyright (c) 1997-2021 The NetBSD Foundation, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + *notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + *notice, this list of conditions and the following disclaimer in the + *documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef OSSAUDIO_INTERNAL_H +#define OSSAUDIO_INTERNAL_H + +#include +#include "soundcard.h" +#undef ioctl + +#define TO_OSSVOL(x) (((x) * 100 + 127) / 255) +#define FROM_OSSVOL(x) x) > 100 ? 100 : (x)) * 255 + 50) / 100) + +#define INTARG (*(int*)argp) + +#define GET_DEV(com) ((com) & 0xff) + +#define oss_private __attribute__((__visibility__("hidden"))) + +int _oss_ioctl(int, unsigned long, ...); + +oss_private int _oss_dsp_ioctl(int, unsigned long, void *); +oss_private int _oss_get_caps(int, int *); +oss_private int _oss3_mixer_ioctl(int, unsigned long, void *); +oss_private int _oss4_mixer_ioctl(int, unsigned long, void *); +oss_private int _oss4_global_ioctl(int, unsigned long, void *); + +#endif Index: src/lib/libossaudio/oss3_mixer.c diff -u /dev/null src/lib/libossaudio/oss3_mixer.c:1.1 --- /dev/null Tue Jun 8 18:43:54 2021 +++ src/lib/libossaudio/oss3_mixer.c Tue Jun 8 18:43:54 2021 @@ -0,0 +1,393 @@ +/* $NetBSD: oss3_mixer.c,v 1.1 2021/06/08 18:43:54 nia Exp $ */ + +/*- + * Copyright (c) 1997-2021 The NetBSD Foundation, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + *notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + *notice, this list of conditions and the following disclaimer in the + *documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE
CVS commit: src/lib/libc/sys
Module Name:src Committed By: nia Date: Tue Jun 8 16:15:12 UTC 2021 Modified Files: src/lib/libc/sys: vfork.2 Log Message: vfork.2: recommend posix_spawn instead To generate a diff of this commit: cvs rdiff -u -r1.28 -r1.29 src/lib/libc/sys/vfork.2 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/sys/vfork.2 diff -u src/lib/libc/sys/vfork.2:1.28 src/lib/libc/sys/vfork.2:1.29 --- src/lib/libc/sys/vfork.2:1.28 Sat May 19 05:39:21 2018 +++ src/lib/libc/sys/vfork.2 Tue Jun 8 16:15:11 2021 @@ -1,4 +1,4 @@ -.\" $NetBSD: vfork.2,v 1.28 2018/05/19 05:39:21 kamil Exp $ +.\" $NetBSD: vfork.2,v 1.29 2021/06/08 16:15:11 nia Exp $ .\" .\" Copyright (c) 1980, 1991, 1993 .\" The Regents of the University of California. All rights reserved. @@ -29,7 +29,7 @@ .\" .\" @(#)vfork.2 8.1 (Berkeley) 6/4/93 .\" -.Dd May 19, 2018 +.Dd June 8, 2021 .Dt VFORK 2 .Os .Sh NAME @@ -105,7 +105,8 @@ Same as for .Xr execve 2 , .Xr fork 2 , .Xr sigaction 2 , -.Xr wait 2 +.Xr wait 2 , +.Xr posix_spawn 3 .Sh HISTORY The .Fn vfork @@ -137,3 +138,6 @@ or signals; rather, output or .Xr ioctl 2 calls are allowed and input attempts result in an end-of-file indication. +.Pp +New applications should prefer +.Xr posix_spawn 3 .
CVS commit: [netbsd-8] src/doc
Module Name:src Committed By: martin Date: Tue Jun 8 13:01:10 UTC 2021 Modified Files: src/doc [netbsd-8]: CHANGES-8.3 Log Message: Ticket #1683 To generate a diff of this commit: cvs rdiff -u -r1.1.2.90 -r1.1.2.91 src/doc/CHANGES-8.3 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/doc/CHANGES-8.3 diff -u src/doc/CHANGES-8.3:1.1.2.90 src/doc/CHANGES-8.3:1.1.2.91 --- src/doc/CHANGES-8.3:1.1.2.90 Sat Jun 5 10:58:28 2021 +++ src/doc/CHANGES-8.3 Tue Jun 8 13:01:10 2021 @@ -1,4 +1,4 @@ -# $NetBSD: CHANGES-8.3,v 1.1.2.90 2021/06/05 10:58:28 martin Exp $ +# $NetBSD: CHANGES-8.3,v 1.1.2.91 2021/06/08 13:01:10 martin Exp $ A complete list of changes from the NetBSD 8.2 release to the NetBSD 8.3 release: @@ -1949,3 +1949,8 @@ sys/dev/pci/if_iwmreg.h1.8 iwm(4): fix various bit declarations - use unsigned for 2^32. [nia, ticket #1682] +sbin/dump/tape.c1.56 + + dump(8): prevent crashes for large file systems. + [hannken, ticket #1683] +
CVS commit: [netbsd-8] src/sbin/dump
Module Name:src Committed By: martin Date: Tue Jun 8 12:59:32 UTC 2021 Modified Files: src/sbin/dump [netbsd-8]: tape.c Log Message: Pull up following revision(s) (requested by hannken in ticket #1683): sbin/dump/tape.c: revision 1.56 Bitmaps (TS_BITS and TS_CLRI) dont use the "c_addr" array as they cannot have holes. As bitmaps are written without TS_ADDR records "c_count" may be larger than the "c_addr" size resulting in a segmentation violation reading "c_addr" beyond its end. Compute "blks" for TS_INODE and TS_ADDR only -- its used for multi volume dumps and the bitmaps must both be on the first volume. To generate a diff of this commit: cvs rdiff -u -r1.54.8.1 -r1.54.8.2 src/sbin/dump/tape.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sbin/dump/tape.c diff -u src/sbin/dump/tape.c:1.54.8.1 src/sbin/dump/tape.c:1.54.8.2 --- src/sbin/dump/tape.c:1.54.8.1 Fri Mar 29 19:43:28 2019 +++ src/sbin/dump/tape.c Tue Jun 8 12:59:32 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: tape.c,v 1.54.8.1 2019/03/29 19:43:28 martin Exp $ */ +/* $NetBSD: tape.c,v 1.54.8.2 2021/06/08 12:59:32 martin Exp $ */ /*- * Copyright (c) 1980, 1991, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)tape.c 8.4 (Berkeley) 5/1/95"; #else -__RCSID("$NetBSD: tape.c,v 1.54.8.1 2019/03/29 19:43:28 martin Exp $"); +__RCSID("$NetBSD: tape.c,v 1.54.8.2 2021/06/08 12:59:32 martin Exp $"); #endif #endif /* not lint */ @@ -328,7 +328,8 @@ flushtape(void) } blks = 0; - if (iswap32(spcl.c_type) != TS_END) { + if (iswap32(spcl.c_type) == TS_INODE || + iswap32(spcl.c_type) == TS_ADDR) { for (i = 0; i < iswap32(spcl.c_count); i++) if (spcl.c_addr[i] != 0) blks++;
CVS commit: [netbsd-9] src/doc
Module Name:src Committed By: martin Date: Tue Jun 8 12:56:29 UTC 2021 Modified Files: src/doc [netbsd-9]: CHANGES-9.3 Log Message: Ticket #1283 To generate a diff of this commit: cvs rdiff -u -r1.1.2.5 -r1.1.2.6 src/doc/CHANGES-9.3 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/doc/CHANGES-9.3 diff -u src/doc/CHANGES-9.3:1.1.2.5 src/doc/CHANGES-9.3:1.1.2.6 --- src/doc/CHANGES-9.3:1.1.2.5 Sat Jun 5 10:56:18 2021 +++ src/doc/CHANGES-9.3 Tue Jun 8 12:56:29 2021 @@ -1,4 +1,4 @@ -# $NetBSD: CHANGES-9.3,v 1.1.2.5 2021/06/05 10:56:18 martin Exp $ +# $NetBSD: CHANGES-9.3,v 1.1.2.6 2021/06/08 12:56:29 martin Exp $ A complete list of changes from the NetBSD 9.2 release to the NetBSD 9.3 release: @@ -82,3 +82,8 @@ sys/dev/pci/if_iwmreg.h1.8 iwm(4): fix various bit declarations - use unsigned for 2^32. [nia, ticket #1282] +sbin/dump/tape.c1.56 + + dump(8): prevent crashes for large file systems. + [hannken, ticket #1283] +
CVS commit: [netbsd-9] src/sbin/dump
Module Name:src Committed By: martin Date: Tue Jun 8 12:55:40 UTC 2021 Modified Files: src/sbin/dump [netbsd-9]: tape.c Log Message: Pull up following revision(s) (requested by hannken in ticket #1283): sbin/dump/tape.c: revision 1.56 Bitmaps (TS_BITS and TS_CLRI) dont use the "c_addr" array as they cannot have holes. As bitmaps are written without TS_ADDR records "c_count" may be larger than the "c_addr" size resulting in a segmentation violation reading "c_addr" beyond its end. Compute "blks" for TS_INODE and TS_ADDR only -- its used for multi volume dumps and the bitmaps must both be on the first volume. To generate a diff of this commit: cvs rdiff -u -r1.55 -r1.55.2.1 src/sbin/dump/tape.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sbin/dump/tape.c diff -u src/sbin/dump/tape.c:1.55 src/sbin/dump/tape.c:1.55.2.1 --- src/sbin/dump/tape.c:1.55 Fri Mar 1 16:42:11 2019 +++ src/sbin/dump/tape.c Tue Jun 8 12:55:40 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: tape.c,v 1.55 2019/03/01 16:42:11 christos Exp $ */ +/* $NetBSD: tape.c,v 1.55.2.1 2021/06/08 12:55:40 martin Exp $ */ /*- * Copyright (c) 1980, 1991, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)tape.c 8.4 (Berkeley) 5/1/95"; #else -__RCSID("$NetBSD: tape.c,v 1.55 2019/03/01 16:42:11 christos Exp $"); +__RCSID("$NetBSD: tape.c,v 1.55.2.1 2021/06/08 12:55:40 martin Exp $"); #endif #endif /* not lint */ @@ -328,7 +328,8 @@ flushtape(void) } blks = 0; - if (iswap32(spcl.c_type) != TS_END) { + if (iswap32(spcl.c_type) == TS_INODE || + iswap32(spcl.c_type) == TS_ADDR) { for (i = 0; i < iswap32(spcl.c_count); i++) if (spcl.c_addr[i] != 0) blks++;
CVS commit: src/lib/libc/sys
Module Name:src Committed By: hannken Date: Tue Jun 8 10:02:04 UTC 2021 Modified Files: src/lib/libc/sys: nfssvc.2 Log Message: Document NFSSVC_REPLACEEXPORTSLIST instead of NFSSVC_SETEXPORTSLIST. The latter is deprecated and kept only for backwards compatibility. To generate a diff of this commit: cvs rdiff -u -r1.24 -r1.25 src/lib/libc/sys/nfssvc.2 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/sys/nfssvc.2 diff -u src/lib/libc/sys/nfssvc.2:1.24 src/lib/libc/sys/nfssvc.2:1.25 --- src/lib/libc/sys/nfssvc.2:1.24 Tue Mar 10 21:00:47 2009 +++ src/lib/libc/sys/nfssvc.2 Tue Jun 8 10:02:04 2021 @@ -1,4 +1,4 @@ -.\" $NetBSD: nfssvc.2,v 1.24 2009/03/10 21:00:47 joerg Exp $ +.\" $NetBSD: nfssvc.2,v 1.25 2021/06/08 10:02:04 hannken Exp $ .\" .\" Copyright (c) 1989, 1991, 1993 .\" The Regents of the University of California. All rights reserved. @@ -29,7 +29,7 @@ .\" .\" @(#)nfssvc.2 8.1 (Berkeley) 6/9/93 .\" -.Dd December 30, 2006 +.Dd June 8, 2021 .Dt NFSSVC 2 .Os .Sh NAME @@ -138,10 +138,10 @@ The server daemon calls .Fn nfssvc with the flag -.Dv NFSSVC_SETEXPORTSLIST +.Dv NFSSVC_REPLACEEXPORTSLIST and a pointer to a .Ft struct mountd_exports_list -object to atomically change the exports lists of a specific file system. +object to atomically replace the exports lists of a specific file system. This structure has the following fields: .Bl -tag -width ".Vt const char *mel_path" .It Vt const char *mel_path
CVS commit: src/sys/dev/audio
Module Name:src Committed By: riastradh Date: Tue Jun 8 09:46:04 UTC 2021 Modified Files: src/sys/dev/audio: audio.c Log Message: audio(4): Revert revision 1.96 and redo it another way. Instead of refusing to open /dev/audioN for writes when the device doesn't support playback, just refuse to issue writes. Although it seems more sensible to me to reject writable opens early on, and it seems Solaris does so, this makes querying device properties a little trickier and is a change to the NetBSD semantics. To generate a diff of this commit: cvs rdiff -u -r1.103 -r1.104 src/sys/dev/audio/audio.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/audio/audio.c diff -u src/sys/dev/audio/audio.c:1.103 src/sys/dev/audio/audio.c:1.104 --- src/sys/dev/audio/audio.c:1.103 Fri Jun 4 08:57:05 2021 +++ src/sys/dev/audio/audio.c Tue Jun 8 09:46:04 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: audio.c,v 1.103 2021/06/04 08:57:05 riastradh Exp $ */ +/* $NetBSD: audio.c,v 1.104 2021/06/08 09:46:04 riastradh Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -138,7 +138,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.103 2021/06/04 08:57:05 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.104 2021/06/08 09:46:04 riastradh Exp $"); #ifdef _KERNEL_OPT #include "audio.h" @@ -2255,20 +2255,10 @@ audio_open(dev_t dev, struct audio_softc af = kmem_zalloc(sizeof(*af), KM_SLEEP); af->sc = sc; af->dev = dev; - if (flags & FWRITE) { - if (!audio_can_playback(sc)) { - error = ENXIO; - goto bad; - } + if ((flags & FWRITE) != 0 && audio_can_playback(sc)) af->mode |= AUMODE_PLAY | AUMODE_PLAY_ALL; - } - if (flags & FREAD) { - if (!audio_can_capture(sc)) { - error = ENXIO; - goto bad; - } + if ((flags & FREAD) != 0 && audio_can_capture(sc)) af->mode |= AUMODE_RECORD; - } if (af->mode == 0) { error = ENXIO; goto bad; @@ -2821,7 +2811,8 @@ audio_write(struct audio_softc *sc, stru int error; track = file->ptrack; - KASSERT(track); + if (track == NULL) + return EPERM; /* I think it's better than EINVAL. */ if (track->mmapped)
CVS commit: src/sys/dev/pad
Module Name:src Committed By: nia Date: Tue Jun 8 09:09:29 UTC 2021 Modified Files: src/sys/dev/pad: pad.c Log Message: pad(4): run the callout if the buffer is saturated instead of returning reverts to the same behavior as in -8 and -9. prevents immediate failures and device timeouts if there's a slight delay in the buffer being consumed. this is reproducible with the example in the man page that uses ffmpeg to record the output of audioplay: $ ffmpeg -f s16le -ar 44100 -ac 2 -i /dev/pad0 output.wav $ audioplay -d /dev/audio1 input.wav if output.wav already exists, ffmpeg will prompt for confirmation to overwrite as soon as audioplay starts, causing a noticable delay, followed by a write failure that causes audioplay to immediately exit. To generate a diff of this commit: cvs rdiff -u -r1.65 -r1.66 src/sys/dev/pad/pad.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pad/pad.c diff -u src/sys/dev/pad/pad.c:1.65 src/sys/dev/pad/pad.c:1.66 --- src/sys/dev/pad/pad.c:1.65 Sun Feb 23 04:02:46 2020 +++ src/sys/dev/pad/pad.c Tue Jun 8 09:09:28 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: pad.c,v 1.65 2020/02/23 04:02:46 isaki Exp $ */ +/* $NetBSD: pad.c,v 1.66 2021/06/08 09:09:28 nia Exp $ */ /*- * Copyright (c) 2007 Jared D. McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: pad.c,v 1.65 2020/02/23 04:02:46 isaki Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pad.c,v 1.66 2021/06/08 09:09:28 nia Exp $"); #include #include @@ -622,14 +622,12 @@ pad_start_output(void *opaque, void *blo err = pad_add_block(sc, block, blksize); mutex_exit(>sc_cond_lock); cv_broadcast(>sc_condvar); - if (err) - return err; ms = blksize * 1000 / PADCHAN / (PADPREC / NBBY) / PADFREQ; DPRINTF("%s: callout ms=%d\n", __func__, ms); callout_reset(>sc_pcallout, mstohz(ms), pad_done_output, sc); - return 0; + return err; } static int