From nobody@FreeBSD.org  Sat Aug 17 05:46:01 2002
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id E3F5737B400
	for <freebsd-gnats-submit@FreeBSD.org>; Sat, 17 Aug 2002 05:46:00 -0700 (PDT)
Received: from www.freebsd.org (www.FreeBSD.org [216.136.204.117])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 9428243E65
	for <freebsd-gnats-submit@FreeBSD.org>; Sat, 17 Aug 2002 05:46:00 -0700 (PDT)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.12.4/8.12.4) with ESMTP id g7HCjxOT042056
	for <freebsd-gnats-submit@FreeBSD.org>; Sat, 17 Aug 2002 05:45:59 -0700 (PDT)
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.12.4/8.12.4/Submit) id g7HCjxdR042055;
	Sat, 17 Aug 2002 05:45:59 -0700 (PDT)
Message-Id: <200208171245.g7HCjxdR042055@www.freebsd.org>
Date: Sat, 17 Aug 2002 05:45:59 -0700 (PDT)
From: Ulrich Spoerlein <q@uni.de>
To: freebsd-gnats-submit@FreeBSD.org
Subject: quake won't play sound with newpcm driver
X-Send-Pr-Version: www-1.0

>Number:         41747
>Category:       kern
>Synopsis:       quake won't play sound with newpcm driver
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sat Aug 17 05:50:01 PDT 2002
>Closed-Date:    Thu Feb 27 11:11:38 PST 2003
>Last-Modified:  Thu Feb 27 11:11:38 PST 2003
>Originator:     Ulrich Spoerlein
>Release:        4.6.2-RELEASE
>Organization:
>Environment:
FreeBSD roadrunner 4.6.2-RELEASE FreeBSD 4.6.2-RELEASE #6: Fri Aug 16 22:01:06 CEST 2002 root@coyote.dnsalias.net:/usr/obj/usr/src/sys/ROADRUNNER  i386

>Description:
when using the voxware drivers, sound in a native compiled quake2 works. when using the pcm driver it says:
/dev/dsp: Invalid argument
SNDDMA_Init: Could not set /dev/dsp to stereo=2
>How-To-Repeat:
with a Soundblaster ISA Card you can try both, voxware and pcm drivers. try one kernel with the voxware driver:
#voxware driver
#device     snd0
#device     sb0      at isa? port 0x220 irq 5 drq 1

and another with the pcm driver:
#pcm driver
#device      pcm
#device      sbc0     at isa? port 0x220 irq 5 drq 1 flags 0x0

right now you have to get the quake2 sources from CVS:
cvs -d :pserver:anonymous@cvs.quakeforge.net:/project/cvs login
cvs -d :pserver:anonymous@cvs.quakeforge.net:/project/cvs checkout quake2

the password is empty. after download finishes:
cd quake2 && ./bootstrap && ./configure && make
>Fix:

>Release-Note:
>Audit-Trail:

From: Orion Hodson <orion@FreeBSD.org>
To: freebsd-gnats-submit@FreeBSD.org, q@uni.de
Cc:  
Subject: Re: kern/41747: quake won't play sound with newpcm driver
Date: Sun, 18 Aug 2002 19:26:09 -0700

 Ulrich, try re-arranging the initialization code in bsd/snd_bsd.c so
 that mmap() comes after the format option ioctls have been made.
 
 Cheers
 - Orion

From: Ulrich 'Q' Spoerlein <q@uni.de>
To: freebsd-gnats-submit@FreeBSD.org
Cc: Orion Hodson <orion@FreeBSD.org>
Subject: Re: kern/41747: quake won't play sound with newpcm driver
Date: Thu, 22 Aug 2002 11:27:56 +0200

 Hello again, thanks for your reply.
 
 moving the mmap() stuff down, resulted in "moving the error message
 down". that means putting mmap() after the setting to stereo resulted in
 "SNDDMA_Init: Could not set /dev/dsp speed to 11025."
 
 i put it right before the soundthread starts up, and get a bus error like
 this:
 ------- sound initialization -------
 sound sampling rate: 11025
 zsh: 72073 bus error (core dumped)  quake2
 
 btw, _don't_ edit the bsd/snd_bsd.c file, it has been merged into
 src/snd.c (the bsd/ directory is obsolete)
 
 another thing to mention is that the same error plagues the quake2 linux
 binary from id Software and the cinematics in Quake3 (in-game sound in
 Quake3 works though, it's just the cinematics)
 
 i can remember some guy telling me that sound in Quake2 was possible for
 him up to FreeBSD 4.2 (or was it 4.3?). i will now try to get the pcm
 driver from 4.2-RELEASE into my kernel and pin down the exact CVS commit
 responsible for breaking the sound in quake2.
 
 btw, do you by any chance know how i get the /src/sys/dev/sound directory
 from 4.2-RELEASE into my sources?

From: "Ulrich 'Q' Spoerlein" <q@uni.de>
To: freebsd-gnats-submit@FreeBSD.org, q@uni.de,
	Orion Hodson <orion@FreeBSD.org>
Cc:  
Subject: Re: kern/41747: quake won't play sound with newpcm driver
Date: Mon, 18 Nov 2002 20:21:26 +0100

 So,
 
 after several MFCs of the -current pcm-driver, this problem still exists,
 and is not limited to Quake.
 
 Maxim Sobolev posted a thread on -multimedia with a small test program
 triggering the issue on -STABLE (but not on -CURRENT). It looks like the
 pcm driver or the mmap() call need/want read-write access to the device
 (though write-only access should be fine)
 
 this code breaks on -STABLE:
 
 #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);
 /*	Changing this to read/write access....
 	fd = open("/dev/dsp", O_RDWR); 
 */
         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);
 /*	...and this to read/write works
 	p = mmap(NULL, info.fragstotal * info.fragsize, PROT_READ|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);
 }
State-Changed-From-To: open->closed 
State-Changed-By: luoqi 
State-Changed-When: Thu Feb 27 11:10:19 PST 2003 
State-Changed-Why:  
Problem solved. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=41747 
>Unformatted:
