NetBSD Problem Report #34647
From gson@gson.org Thu Sep 28 10:05:03 2006
Return-Path: <gson@gson.org>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
by narn.NetBSD.org (Postfix) with ESMTP id 35D7B63B8CA
for <gnats-bugs@gnats.NetBSD.org>; Thu, 28 Sep 2006 10:05:03 +0000 (UTC)
Message-Id: <20060928085409.F340875EED@guava.gson.org>
Date: Thu, 28 Sep 2006 11:54:09 +0300 (EEST)
From: gson@gson.org (Andreas Gustafsson)
Reply-To: gson@gson.org (Andreas Gustafsson)
To: gnats-bugs@NetBSD.org
Subject: audio(4) silence insertion is broken
X-Send-Pr-Version: 3.95
>Number: 34647
>Category: kern
>Synopsis: audio(4) silence insertion is broken
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: nat
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Thu Sep 28 10:10:00 +0000 2006
>Closed-Date: Sun Jun 18 14:59:51 +0000 2017
>Last-Modified: Sun Jun 18 14:59:51 +0000 2017
>Originator: Andreas Gustafsson
>Release: NetBSD 3.99.24
>Organization:
>Environment:
System: NetBSD guava.gson.org 3.99.24 NetBSD 3.99.24 (GENERIC) #0: Fri Aug 4 13:14:16 EEST 2006 root@guru.araneus.fi:/usr/build/1005/obj/sys/arch/i386/compile/GENERIC i386
Architecture: i386
Machine: i386
>Description:
The audio(4) man page states:
If a writing process does not call write(2) frequently enough to
provide samples at the pace the hardware consumes them silence is
inserted.
In actuality, random noises appear in the audio output in this
situation. I have observed this behavior on two different machines,
one having an Ensoniq AudioPCI (eap(4)) and the other having an Acer
Labs M5451 (autri(4)), which leads me to believe that the problem is
in the generic audio(4) framework rather than in any one specific
hardware driver.
>How-To-Repeat:
Compile and run the following program, for example by saving it as
test.c and running "cc test.c -lm && ./a.out":
#include <fcntl.h>
#include <memory.h>
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char **argv) {
int fd;
char buf[4000];
fd = open("/dev/audio", O_WRONLY);
if (fd == -1) {
fprintf(stderr, "could not open /dev/audio\n");
exit(1);
}
memset(buf, 0, sizeof buf);
write(fd, buf, sizeof buf);
sleep(10);
exit(0);
}
This should play half a second of silence followed by another ten
seconds of silence inserted by the audio driver due to lack of data;
any sound appearing appearing on the sound card output means you
are suffering from the bug.
>Fix:
None provided.
>Release-Note:
>Audit-Trail:
From: gson@gson.org (Andreas Gustafsson)
To: gnats-bugs@NetBSD.org
Cc:
Subject: Re: kern/34647: audio(4) silence insertion is broken
Date: Tue, 3 Jun 2008 19:52:40 +0300
The original test program included in kern/34647 has a slight bug;
it should use bytes 0xff rather than 0x00 for silence since the
default /dev/audio encoding is mu-law. As a result, running it
will result in a pair of clicks even when running it on a correctly
working system.
Here is an updated test program, which uses the correct silence
value and does not produce the clicks. It has also been changed
to repeat the test indefinitely rather than just doing it once.
#include <fcntl.h>
#include <memory.h>
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char **argv) {
int fd;
char buf[4000];
fd = open("/dev/audio", O_WRONLY);
if (fd == -1) {
fprintf(stderr, "could not open /dev/audio\n");
exit(1);
}
memset(buf, 0xff, sizeof buf);
for (;;) {
write(fd, buf, sizeof buf);
sleep(1);
}
return 0;
}
If I play some audio and then run the test program on a machine with
an eap sound card and a kernel built from -current source as of
20080516-1010 EET, I still get noise sounding like fragments of the
previously played audio (not just clicks) for a few seconds.
If the test program is run multiple times, you need to play back some
non-silent audio between the runs to ensure that the audio buffers
do not already contain silence, for example by running
dd if=/dev/urandom of=/dev/audio bs=32k count=1
--
Andreas Gustafsson, gson@gson.org
Responsible-Changed-From-To: kern-bug-people->nat
Responsible-Changed-By: nat@NetBSD.org
Responsible-Changed-When: Wed, 12 Apr 2017 14:02:35 +0000
Responsible-Changed-Why:
Take.
From: "Nathanial Sloss" <nat@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/34647 CVS commit: src/sys/dev
Date: Wed, 12 Apr 2017 14:15:51 +0000
Module Name: src
Committed By: nat
Date: Wed Apr 12 14:15:51 UTC 2017
Modified Files:
src/sys/dev: audio.c
Log Message:
Insert silence into the mix ring if there is no audio (or audio cannot
keep up) from the channels.
Addresses PR kern/34647.
To generate a diff of this commit:
cvs rdiff -u -r1.321 -r1.322 src/sys/dev/audio.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
State-Changed-From-To: open->feedback
State-Changed-By: nat@NetBSD.org
State-Changed-When: Wed, 12 Apr 2017 14:24:46 +0000
State-Changed-Why:
A change has been committed to address this.
From: Andreas Gustafsson <gson@gson.org>
To: nat@NetBSD.org
Cc: gnats-bugs@NetBSD.org
Subject: Re: kern/34647 (audio(4) silence insertion is broken)
Date: Sun, 18 Jun 2017 17:51:17 +0300
On April 12, nat@NetBSD.org wrote:
> A change has been committed to address this.
I have now tried the test program from the PR on a -current system with
hdafg0 at hdaudio0: vendor 11d4 product 184a
and verified that there are no audible clicks or other noises.
Thank you!
--
Andreas Gustafsson, gson@gson.org
State-Changed-From-To: feedback->closed
State-Changed-By: gson@NetBSD.org
State-Changed-When: Sun, 18 Jun 2017 14:59:51 +0000
State-Changed-Why:
Confirmed fixed.
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2014
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.