From jylefort@brutele.be  Sun Aug 13 06:18:48 2006
Return-Path: <jylefort@brutele.be>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id ED0A716A4DF
	for <FreeBSD-gnats-submit@freebsd.org>; Sun, 13 Aug 2006 06:18:48 +0000 (UTC)
	(envelope-from jylefort@brutele.be)
Received: from mirapoint5.brutele.be (mirapoint5.brutele.be [212.68.199.150])
	by mx1.FreeBSD.org (Postfix) with ESMTP id B016743D46
	for <FreeBSD-gnats-submit@freebsd.org>; Sun, 13 Aug 2006 06:18:47 +0000 (GMT)
	(envelope-from jylefort@brutele.be)
Received: from host-212-68-244-243.brutele.be (host-212-68-244-243.brutele.be [212.68.244.243])
	by mirapoint5.brutele.be (MOS 3.7.5-GA)
	with ESMTP id ELO09311;
	Sun, 13 Aug 2006 08:18:42 +0200 (CEST)
Received: from jsite.lefort.net (jsite.lefort.net [192.168.1.2])
	by gateway.lefort.net (Postfix) with ESMTP id A6C335531;
	Sun, 13 Aug 2006 08:18:41 +0200 (CEST)
Received: by jsite.lefort.net (Postfix, from userid 1000)
	id DAD5AC0ED; Sun, 13 Aug 2006 08:18:40 +0200 (CEST)
Message-Id: <20060813061840.DAD5AC0ED@jsite.lefort.net>
Date: Sun, 13 Aug 2006 08:18:40 +0200 (CEST)
From: Jean-Yves Lefort <jylefort@FreeBSD.org>
Reply-To: Jean-Yves Lefort <jylefort@FreeBSD.org>
To: FreeBSD-gnats-submit@freebsd.org
Cc: erik@smluc.org
Subject: Update port: audio/openal (customizable audio buffer size)
X-Send-Pr-Version: 3.113

>Number:         101960
>Category:       ports
>Synopsis:       Update port: audio/openal (customizable audio buffer size)
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    jylefort
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          update
>Submitter-Id:   current-users
>Arrival-Date:   Sun Aug 13 06:20:18 GMT 2006
>Closed-Date:    Wed Aug 16 13:28:04 GMT 2006
>Last-Modified:  Tue Aug 22 23:10:15 GMT 2006
>Originator:     Jean-Yves Lefort
>Release:        FreeBSD 6.1-RELEASE i386
>Organization:
>Environment:
System: FreeBSD jsite.lefort.net 6.1-RELEASE FreeBSD 6.1-RELEASE #0: Tue May 9 22:34:08 CEST 2006 jylefort@jsite.lefort.net:/usr/obj/usr/src/sys/JSITE i386
>Description:
- Allow to customize the audio buffer size (see pkg-message for the point).
- Take maintainership.
>How-To-Repeat:
>Fix:
diff -ruN /usr/ports/audio/openal/Makefile openal/Makefile
--- /usr/ports/audio/openal/Makefile	Wed Jul  5 19:54:22 2006
+++ openal/Makefile	Sun Aug 13 08:07:04 2006
@@ -7,12 +7,12 @@
 
 PORTNAME=	openal
 PORTVERSION=	20060211
-PORTREVISION=	2
+PORTREVISION=	3
 CATEGORIES=	audio
 MASTER_SITES=	http://openal.org/openal_webstf/downloads/
 DISTVERSION=	0.0.8
 
-MAINTAINER=	erik@smluc.org
+MAINTAINER=	jylefort@FreeBSD.org
 COMMENT=	A 3D positional spatialized sound library
 
 GNU_CONFIGURE=	yes
@@ -87,5 +87,8 @@
 		s|Libs: |&${PTHREAD_LIBS} |;\
 		s|Cflags: |&${PTHREAD_CFLAGS} |' \
 		${WRKSRC}/admin/pkgconfig/openal.pc.in
+
+post-install:
+	@${CAT} ${PKGMESSAGE}
 
 .include <bsd.port.post.mk>
diff -ruN /usr/ports/audio/openal/files/patch-src-backends-alc_backend_bsd.c openal/files/patch-src-backends-alc_backend_bsd.c
--- /usr/ports/audio/openal/files/patch-src-backends-alc_backend_bsd.c	Sun Apr 23 21:46:44 2006
+++ openal/files/patch-src-backends-alc_backend_bsd.c	Sun Aug 13 07:59:51 2006
@@ -1,5 +1,5 @@
---- src/backends/alc_backend_bsd.c.orig	Sat Apr 22 12:25:15 2006
-+++ src/backends/alc_backend_bsd.c	Sat Apr 22 12:26:15 2006
+--- src/backends/alc_backend_bsd.c.orig	Thu Jan  5 16:11:20 2006
++++ src/backends/alc_backend_bsd.c	Sun Aug 13 07:39:16 2006
 @@ -9,7 +9,10 @@
   */
  #include "al_siteconfig.h"
@@ -11,49 +11,55 @@
  #include <assert.h>
  #include <fcntl.h>
  #include <sys/soundcard.h>
-@@ -113,7 +114,6 @@
+@@ -113,7 +116,6 @@
   */
  static void *grab_write_native(void) {
-	const char *dsppath = "/dev/dsp";
+ 	const char *dsppath = "/dev/dsp";
 -	int divisor = _alSpot(_AL_DEF_BUFSIZ) | (2<<16);
-
-	dsp_fd = open(dsppath, O_WRONLY | O_NONBLOCK);
-
-@@ -126,10 +126,6 @@
-		perror("fcntl");
-	}
-
+ 
+ 	dsp_fd = open(dsppath, O_WRONLY | O_NONBLOCK);
+ 
+@@ -126,10 +128,6 @@
+ 		perror("fcntl");
+ 	}
+ 
 -	if(ioctl(dsp_fd, SNDCTL_DSP_SETFRAGMENT, &divisor) < 0) {
 -		perror("ioctl SETFRAGMENT");
 -	}
 -
-	FD_ZERO(&dsp_fd_set);
-	FD_SET(dsp_fd, &dsp_fd_set);
-
-@@ -318,10 +314,11 @@
+ 	FD_ZERO(&dsp_fd_set);
+ 	FD_SET(dsp_fd, &dsp_fd_set);
+ 
+@@ -318,10 +316,12 @@
  }
-
+ 
  static ALboolean set_write_native(UNUSED(void *handle),
 -				  UNUSED(unsigned int *bufsiz),
 +				  unsigned int *bufsiz,
-				  ALenum *fmt,
-				  unsigned int *speed) {
-	ALuint channels = _alGetChannelsFromFormat(*fmt);
+ 				  ALenum *fmt,
+ 				  unsigned int *speed) {
+ 	ALuint channels = _alGetChannelsFromFormat(*fmt);
 +	int divisor;
-
-	if(dsp_fd < 0) {
-		return AL_FALSE;
-@@ -363,6 +360,23 @@
-
-
-	*fmt = BSD2ALFMT(*fmt, channels);
++	char *custom_bufsiz;
+ 
+ 	if(dsp_fd < 0) {
+ 		return AL_FALSE;
+@@ -363,6 +363,28 @@
+ 
+ 
+ 	*fmt = BSD2ALFMT(*fmt, channels);
 +
-+	if(ioctl(dsp_fd, SNDCTL_DSP_GETBLKSIZE, bufsiz) < 0) {
++	custom_bufsiz = getenv("OPENAL_BUFFER_SIZE");
++	if (custom_bufsiz != NULL)
++		*bufsiz = atoi(custom_bufsiz);
++	else {
++		if(ioctl(dsp_fd, SNDCTL_DSP_GETBLKSIZE, bufsiz) < 0) {
 +#ifdef DEBUG_MAXIMUS
-+		fprintf(stderr, "blksize %d\n", *bufsiz);
-+		perror("get_devsp blksize ioctl");
++			fprintf(stderr, "blksize %d\n", *bufsiz);
++			perror("get_devsp blksize ioctl");
 +#endif
-+		return AL_FALSE;
++			return AL_FALSE;
++		}
 +	}
 +
 +	divisor = _alSpot(*bufsiz) | (2<<16);
@@ -64,6 +70,6 @@
 +#endif
 +		return AL_FALSE;
 +	}
-
-	return AL_TRUE;
+ 
+ 	return AL_TRUE;
  }
diff -ruN /usr/ports/audio/openal/pkg-message openal/pkg-message
--- /usr/ports/audio/openal/pkg-message	Thu Jan  1 01:00:00 1970
+++ openal/pkg-message	Sun Aug 13 08:06:42 2006
@@ -0,0 +1,14 @@
+===============================================================================
+If you hear cracks and pops with some applications, adjust the
+OPENAL_BUFFER_SIZE environment variable, for instance:
+
+	export OPENAL_BUFFER_SIZE=8192
+	fgfs
+
+If the OPENAL_BUFFER_SIZE environment variable is not set, the default sound
+card buffer size is used.
+
+Increasing the audio buffer size increases the audio latency but decreases the
+CPU usage; decreasing the audio buffer size decreases the audio latency but
+increases the CPU usage (which can cause cracks and pops).
+===============================================================================
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-ports-bugs->jylefort 
Responsible-Changed-By: edwin 
Responsible-Changed-When: Sun Aug 13 06:20:26 UTC 2006 
Responsible-Changed-Why:  
Submitter has GNATS access 

http://www.freebsd.org/cgi/query-pr.cgi?pr=101960 
State-Changed-From-To: open->feedback 
State-Changed-By: edwin 
State-Changed-When: Sun Aug 13 06:20:33 UTC 2006 
State-Changed-Why:  
Awaiting maintainers feedback 

http://www.freebsd.org/cgi/query-pr.cgi?pr=101960 
State-Changed-From-To: feedback->open 
State-Changed-By: linimon 
State-Changed-When: Mon Aug 14 21:52:36 UTC 2006 
State-Changed-Why:  
From misfiled PR ports/102016: 

Date: Sun, 13 Aug 2006 09:49:40 -0500 
From: Erik Greenwald <erik@smluc.org> 

Looks good to me. I'd prefer to retain maintainership unless there is a 
compelling reason for me to surrender it, however. 

Since the openal repository was restructured a couple months ago, I 
can't commit this there as is. I will look into how to splice it in 
without hurting the non-bsd oss users and commit then...  

Thanks! 
-Erik 

http://www.freebsd.org/cgi/query-pr.cgi?pr=101960 
State-Changed-From-To: open->closed 
State-Changed-By: jylefort 
State-Changed-When: Wed Aug 16 13:27:46 UTC 2006 
State-Changed-Why:  
Committed (without maintainer change), thanks. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=101960 

From: Iasen Kostoff <tbyte@otel.net>
To: bug-followup@FreeBSD.org, jylefort@FreeBSD.org
Cc:  
Subject: Re: ports/101960: Update port: audio/openal (customizable audio
	buffer size)
Date: Wed, 23 Aug 2006 01:52:22 +0300

 After upgrading openal from 20060211_2 to 20060211_3 with this patch the
 game Warzone 2100 locks around first clash with the enemy (It looks like
 there need to be many channels mixed, many gunshots fired). Downgrading
 openal to 20060211_2 fixes the problem. I'll try to look into that but I
 thought it would be good to warn You.
 

From: Iasen Kostoff <tbyte@otel.net>
To: bug-followup@FreeBSD.org, jylefort@FreeBSD.org
Cc:  
Subject: Re: ports/101960: Update port: audio/openal (customizable audio
	buffer size)
Date: Wed, 23 Aug 2006 02:05:07 +0300

 Having OPENAL_BUFFER_SIZE set to 8192 fixes the problem. I'm not sure
 why if not set sometimes the game crashes with SIGSEGV and sometimes
 just lock eating 100% of the CPU. Its almost sure that it's not the lack
 of CPU power that causes the problem, it's Athlon64 3700+ with GF6800GT
 on PCI-E so it's possible to be the audio driver or this patch setting
 the buffer too low. The OS is :
 FreeBSD 6.1-STABLE FreeBSD 6.1-STABLE #0: Tue Aug 22 01:57:28 EEST 2006
 and the audio is 'nForce4 AC'97 Audio Controller' (e.g. snd_ich.ko).
 
 
>Unformatted:
