NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: kern/34647: audio(4) silence insertion is broken
The following reply was made to PR kern/34647; it has been noted by GNATS.
From: gson%gson.org@localhost (Andreas Gustafsson)
To: gnats-bugs%NetBSD.org@localhost
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@localhost
Home |
Main Index |
Thread Index |
Old Index