Date: Tue, 22 Oct 2002 19:31:45 +0300 From: Maxim Sobolev <sobomax@FreeBSD.org> To: orion@FreeBSD.org, stable@FreeBSD.org, multimedia@FreeBSD.org Cc: gerald@FreeBSD.org Subject: mmap'ed sound buffer doesn't work in -stable, but works in -current Message-ID: <3DB57D71.5BBB31AE@FreeBSD.org>
next in thread | raw e-mail | index | archive | help
[-- Attachment #1 --]
Folks,
When investigating the problem with running Apple's QuickTime player
under wine in 4.7 (it works like a charm in -current) I've found that
mmap'ed sound buffer doesn't work in -stable, but works in -current.
In -stable, after mmap'ing dsp device any attempt to write into the
mapped memory results in SIGBUS, which obviously kills wine.
Attached please find a simple test case, which illustrates the
problem. The problem has been verified on original Creative SB16 ISA
and Intel 82801BA (ICH2), so that it is unlikely to be an issue with a
specific driver/hardware.
Any ideas what could be wrong? I am puzzled, because the audio code is
essentially the same in -stable and in -current.
Thanks!
-Maxim
[-- Attachment #2 --]
#include <sys/types.h>
#include <sys/mman.h>
#include <sys/soundcard.h>
#include <err.h>
#include <fcntl.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <strings.h>
int bytesok = 0;
void
catch(int signum)
{
printf("Signal %d catched, only %d bytes cleared\n", signum, bytesok);
exit (1);
}
int main()
{
int fd;
audio_buf_info info;
int frags;
void *p;
fd = open("/dev/dsp", O_WRONLY | O_DIRECT);
if (fd == -1)
err(1, "can't open audio device");
frags = 0x0020000B; /* 64K buffer (32 * 2^11) */
if (ioctl(fd, SNDCTL_DSP_SETFRAGMENT, &frags) == -1)
err(1, "can't set fragments");
if (ioctl(fd, SNDCTL_DSP_GETOSPACE, &info) == -1)
err(1, "can't get info about i/o space");
p = mmap(NULL, info.fragstotal * info.fragsize, PROT_WRITE, MAP_SHARED,
fd, 0);
if (p == MAP_FAILED)
err(1, "can't mmap() output buffer");
signal(SIGBUS, catch);
for (bytesok = 0; bytesok < info.fragstotal * info.fragsize; bytesok++)
*((char *)p + bytesok) = 0;
exit (0);
}
[-- Attachment #3 --]
all:
${CC} ${CFLAGS} -o test test.c
clean:
rm -f test
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3DB57D71.5BBB31AE>
