NetBSD Problem Report #55175
From nia@netbsd.org Tue Apr 14 12:06:36 2020
Return-Path: <nia@netbsd.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
by mollari.NetBSD.org (Postfix) with ESMTPS id 6B4251A9219
for <gnats-bugs@gnats.NetBSD.org>; Tue, 14 Apr 2020 12:06:36 +0000 (UTC)
Message-Id: <20200414120636.GA8320@homeworld.netbsd.org>
Date: Tue, 14 Apr 2020 12:06:36 +0000
From: nia <nia@NetBSD.org>
To: gnats-bugs@netbsd.org
Subject: Interpretation of AUDIO_FORMAT_LINEAR is wrong for 8-bit samples
>Number: 55175
>Category: kern
>Synopsis: Interpreation of AUDIO_FORMAT_LINEAR is wrong for 8-bit samples
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: nia
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Tue Apr 14 12:10:00 +0000 2020
>Closed-Date: Thu Aug 20 08:00:22 +0000 2020
>Last-Modified: Thu Aug 20 08:00:22 +0000 2020
>Originator: nia <nia@NetBSD.org>
>Release: NetBSD 9.0_STABLE
>Organization:
>Environment:
System: NetBSD r 9.0_STABLE NetBSD 9.0_STABLE (GENERIC) #13: Mon Apr 13 15:12:50 IST 2020 nia@r:/home/nia/netbsd-9/sys/arch/amd64/compile/obj/GENERIC amd64
Architecture: x86_64
Machine: amd64
>Description:
illumos/Solaris/SunOS define AUDIO_ENCODING_LINEAR as follows:
#define AUDIO_ENCODING_LINEAR (3) /* Signed Linear PCM encoding */
However, in NetBSD, it's an alias for AUDIO_ENCODING_PCM16, which is deprecated.
#define AUDIO_ENCODING_PCM16 3 /* signed linear PCM, obsolete */
#define AUDIO_ENCODING_LINEAR AUDIO_ENCODING_PCM16 /* SunOS compat */
Note that both definitions say the encoding is signed...
In the kernel, PCM16 is interpreted as unsigned if the samples are 8-bit. This seems unexpected and wrong.
I'm not sure of the origin of the definition of PCM16 and as far as I can tell it was never documented in NetBSD, but far more code in the wild uses LINEAR, and even our own headers say it's signed.
>How-To-Repeat:
Attempt to do audio I/O with precision=8 and AUDIO_FORMAT_LINEAR.
>Fix:
Probably this:
Index: audio.c
===================================================================
RCS file: /cvsroot/src/sys/dev/audio/audio.c,v
retrieving revision 1.65
diff -u -r1.65 audio.c
--- audio.c 26 Mar 2020 13:32:03 -0000 1.65
+++ audio.c 14 Apr 2020 11:35:13 -0000
@@ -6086,12 +6086,8 @@
{
/* Convert obsoleted AUDIO_ENCODING_PCM* */
- /* XXX Is this conversion right? */
if (p->encoding == AUDIO_ENCODING_PCM16) {
- if (p->precision == 8)
- p->encoding = AUDIO_ENCODING_ULINEAR;
- else
- p->encoding = AUDIO_ENCODING_SLINEAR;
+ p->encoding = AUDIO_ENCODING_SLINEAR;
} else if (p->encoding == AUDIO_ENCODING_PCM8) {
if (p->precision == 8)
p->encoding = AUDIO_ENCODING_ULINEAR;
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: kern-bug-people->isaki
Responsible-Changed-By: isaki@NetBSD.org
Responsible-Changed-When: Thu, 16 Apr 2020 13:10:45 +0000
Responsible-Changed-Why:
I take it.
From: "Nia Alarie" <nia@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/55175 CVS commit: src/sys/dev/audio
Date: Tue, 26 May 2020 10:12:12 +0000
Module Name: src
Committed By: nia
Date: Tue May 26 10:12:12 UTC 2020
Modified Files:
src/sys/dev/audio: audio.c
Log Message:
audio: Restore compat with Solaris for 8-bit LINEAR.
It's always signed, unless it's LINEAR8.
PR kern/55175
To generate a diff of this commit:
cvs rdiff -u -r1.71 -r1.72 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.
From: Tetsuya Isaki <isaki@pastel-flower.jp>
To: gnats-bugs@netbsd.org
Cc: gnats-admin@netbsd.org,
netbsd-bugs@netbsd.org,
nia <nia@NetBSD.org>
Subject: Re: PR/55175 CVS commit: src/sys/dev/audio
Date: Fri, 29 May 2020 12:26:29 +0900
At Tue, 26 May 2020 10:15:01 +0000 (UTC),
Nia Alarie wrote:
> Module Name: src
> Committed By: nia
> Date: Tue May 26 10:12:12 UTC 2020
>
> Modified Files:
> src/sys/dev/audio: audio.c
>
> Log Message:
> audio: Restore compat with Solaris for 8-bit LINEAR.
>
> It's always signed, unless it's LINEAR8.
This might restore compatibility with Sun but
it breaks compatibility with recent 20+ years NetBSD binary.
I'm not sure which is better.
But anyway, it's too trivial case. I have no futher opinions.
Thanks,
---
Tetsuya Isaki <isaki@pastel-flower.jp / isaki@NetBSD.org>
Responsible-Changed-From-To: isaki->nia
Responsible-Changed-By: isaki@NetBSD.org
Responsible-Changed-When: Fri, 29 May 2020 03:32:24 +0000
Responsible-Changed-Why:
This is no longer mine.
State-Changed-From-To: open->closed
State-Changed-By: nia@NetBSD.org
State-Changed-When: Thu, 20 Aug 2020 08:00:22 +0000
State-Changed-Why:
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.46 2020/01/03 16:35:01 leot Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2020
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.