[Openal-devel] Running OpenAL at 44100 Hz?

Prakash Punnoor prakash at punnoor.de
Thu Nov 24 05:28:22 PST 2005


OK,

this is basically the patch I am using. I don't know whether I put the
variable into the best place. I am open for suggestion. I works for me.
I no one objects I'll merge it.

So to change (external and internal) sampling rate, so something like:

(define sampling-rate 44100)
(define internal-sampling-rate 44100)

in .openalrc

-- 
(°=                 =°)
//\ Prakash Punnoor /\\
V_/                 \_V


diff -Nurd openal/linux/src/alc/alc_context.c
openal.w/linux/src/alc/alc_context.c
--- openal/linux/src/alc/alc_context.c	2005-11-17 14:14:53.000000000 +0100
+++ openal.w/linux/src/alc/alc_context.c	2005-11-24 14:12:42.965437216 +0100
@@ -687,6 +687,10 @@
 	}

 	/* okay, now post process */
+	
+	/* change canon sampling rate if wanted */
+	if (cc->write_device->force_canon_speed)
+		canon_speed = cc->write_device->force_canon_speed;

 	if( refresh_rate > canon_speed ) {
 		/*
diff -Nurd openal/linux/src/alc/alc_device.c
openal.w/linux/src/alc/alc_device.c
--- openal/linux/src/alc/alc_device.c	2005-08-21 10:28:20.000000000 +0200
+++ openal.w/linux/src/alc/alc_device.c	2005-11-24 14:19:36.127627016 +0100
@@ -35,6 +35,7 @@
 	Rcvar foo = NULL;
 	Rcvar direction = NULL;
 	Rcvar freq_sym = NULL;
+	Rcvar internal_freq_sym = NULL;
 	Rcvar speakers = NULL;
 	UNUSED(Rcvar devices) = NULL;
 	int i;
@@ -48,10 +49,11 @@
 	}

 	/* see if the user defined devices, sampling-rate, or direction */
-	devices   = rc_lookup( "devices" );
-	direction = rc_lookup( "direction" );
-	freq_sym  = rc_lookup( "sampling-rate" );
-	speakers  = rc_lookup( "speaker-num" );
+	devices            = rc_lookup( "devices" );
+	direction          = rc_lookup( "direction" );
+	freq_sym           = rc_lookup( "sampling-rate" );
+	internal_freq_sym  = rc_lookup( "internal-sampling-rate" );
+	speakers           = rc_lookup( "speaker-num" );

 	/* get the attributes requested in the args */
 	if( deviceSpecifier ) {
@@ -73,15 +75,21 @@
 	if( freq_sym != NULL ) {
 		rc_define( "sampling-rate", alrc_quote( freq_sym ));
 	}
+	
+	if( internal_freq_sym != NULL ) {
+		rc_define( "internal-sampling-rate", alrc_quote( internal_freq_sym ));
+	}
+	

 	if( speakers != NULL ) {
 		rc_define( "speaker-num", alrc_quote( speakers ));
 	}

-	direction = rc_lookup( "direction" );
-	devices   = rc_lookup( "devices" );
-	freq_sym  = rc_lookup( "sampling-rate" );
-	speakers  = rc_lookup( "speaker-num" );
+	direction         = rc_lookup( "direction" );
+	devices           = rc_lookup( "devices" );
+	freq_sym          = rc_lookup( "sampling-rate" );
+	internal_freq_sym = rc_lookup( "internal-sampling-rate" );
+	speakers          = rc_lookup( "speaker-num" );

 	memset( dirstr, 0, sizeof(dirstr) );
 	
@@ -127,10 +135,11 @@
 	}

 	/* defaults */
-	retval->format = _ALC_EXTERNAL_FMT;
-	retval->speed  = _ALC_EXTERNAL_SPEED;
-	retval->bufsiz = _ALC_DEF_BUFSIZ;
-	retval->flags  = ALCD_NONE;
+	retval->format             = _ALC_EXTERNAL_FMT;
+	retval->speed              = _ALC_EXTERNAL_SPEED;
+	retval->force_canon_speed  = 0;
+	retval->bufsiz             = _ALC_DEF_BUFSIZ;
+	retval->flags              = ALCD_NONE;

 	if( freq_sym != NULL ) {
 		switch(rc_type( freq_sym )) {
@@ -146,6 +155,20 @@
 		}
 	}

+	if( internal_freq_sym != NULL ) {
+		switch(rc_type( internal_freq_sym )) {
+			case ALRC_INTEGER:
+			case ALRC_FLOAT:
+				retval->force_canon_speed = rc_toint( internal_freq_sym );
+				break;
+			default:
+				_alDebug(ALD_CONVERT, __FILE__, __LINE__,
+				         "invalid type %s for internal-sampling-rate",
+				         rc_typestr( rc_type( internal_freq_sym ) ));
+				break;
+		}
+	}
+
 	if( speakers != NULL ) {
 		ALenum fmt;

diff -Nurd openal/linux/src/al_types.h openal.w/linux/src/al_types.h
--- openal/linux/src/al_types.h	2005-11-17 14:14:53.000000000 +0100
+++ openal.w/linux/src/al_types.h	2005-11-24 14:13:14.960573216 +0100
@@ -291,6 +291,7 @@
 	ALenum format;
 	ALuint speed;
 	ALuint bufsiz;
+	ALuint force_canon_speed;

 	DeviceEnum flags;
 	ALubyte *specifier;


-------------- next part --------------
diff -Nurd openal/linux/src/alc/alc_context.c openal.w/linux/src/alc/alc_context.c
--- openal/linux/src/alc/alc_context.c	2005-11-17 14:14:53.000000000 +0100
+++ openal.w/linux/src/alc/alc_context.c	2005-11-24 14:12:42.965437216 +0100
@@ -687,6 +687,10 @@
 	}
 
 	/* okay, now post process */
+	
+	/* change canon sampling rate if wanted */
+	if (cc->write_device->force_canon_speed)
+		canon_speed = cc->write_device->force_canon_speed;
 
 	if( refresh_rate > canon_speed ) {
 		/*
diff -Nurd openal/linux/src/alc/alc_device.c openal.w/linux/src/alc/alc_device.c
--- openal/linux/src/alc/alc_device.c	2005-08-21 10:28:20.000000000 +0200
+++ openal.w/linux/src/alc/alc_device.c	2005-11-24 14:19:36.127627016 +0100
@@ -35,6 +35,7 @@
 	Rcvar foo = NULL;
 	Rcvar direction = NULL;
 	Rcvar freq_sym = NULL;
+	Rcvar internal_freq_sym = NULL;
 	Rcvar speakers = NULL;
 	UNUSED(Rcvar devices) = NULL;
 	int i;
@@ -48,10 +49,11 @@
 	}
 
 	/* see if the user defined devices, sampling-rate, or direction */
-	devices   = rc_lookup( "devices" );
-	direction = rc_lookup( "direction" );
-	freq_sym  = rc_lookup( "sampling-rate" );
-	speakers  = rc_lookup( "speaker-num" );
+	devices            = rc_lookup( "devices" );
+	direction          = rc_lookup( "direction" );
+	freq_sym           = rc_lookup( "sampling-rate" );
+	internal_freq_sym  = rc_lookup( "internal-sampling-rate" );
+	speakers           = rc_lookup( "speaker-num" );
 
 	/* get the attributes requested in the args */
 	if( deviceSpecifier ) {
@@ -73,15 +75,21 @@
 	if( freq_sym != NULL ) {
 		rc_define( "sampling-rate", alrc_quote( freq_sym ));
 	}
+	
+	if( internal_freq_sym != NULL ) {
+		rc_define( "internal-sampling-rate", alrc_quote( internal_freq_sym ));
+	}
+	
 
 	if( speakers != NULL ) {
 		rc_define( "speaker-num", alrc_quote( speakers ));
 	}
 
-	direction = rc_lookup( "direction" );
-	devices   = rc_lookup( "devices" );
-	freq_sym  = rc_lookup( "sampling-rate" );
-	speakers  = rc_lookup( "speaker-num" );
+	direction         = rc_lookup( "direction" );
+	devices           = rc_lookup( "devices" );
+	freq_sym          = rc_lookup( "sampling-rate" );
+	internal_freq_sym = rc_lookup( "internal-sampling-rate" );
+	speakers          = rc_lookup( "speaker-num" );
 
 	memset( dirstr, 0, sizeof(dirstr) );
 	
@@ -127,10 +135,11 @@
 	}
 
 	/* defaults */
-	retval->format = _ALC_EXTERNAL_FMT;
-	retval->speed  = _ALC_EXTERNAL_SPEED;
-	retval->bufsiz = _ALC_DEF_BUFSIZ;
-	retval->flags  = ALCD_NONE;
+	retval->format             = _ALC_EXTERNAL_FMT;
+	retval->speed              = _ALC_EXTERNAL_SPEED;
+	retval->force_canon_speed  = 0;
+	retval->bufsiz             = _ALC_DEF_BUFSIZ;
+	retval->flags              = ALCD_NONE;
 
 	if( freq_sym != NULL ) {
 		switch(rc_type( freq_sym )) {
@@ -146,6 +155,20 @@
 		}
 	}
 
+	if( internal_freq_sym != NULL ) {
+		switch(rc_type( internal_freq_sym )) {
+			case ALRC_INTEGER:
+			case ALRC_FLOAT:
+				retval->force_canon_speed = rc_toint( internal_freq_sym );
+				break;
+			default:
+				_alDebug(ALD_CONVERT, __FILE__, __LINE__,
+				         "invalid type %s for internal-sampling-rate",
+				         rc_typestr( rc_type( internal_freq_sym ) ));
+				break;
+		}
+	}
+
 	if( speakers != NULL ) {
 		ALenum fmt;
 
diff -Nurd openal/linux/src/al_types.h openal.w/linux/src/al_types.h
--- openal/linux/src/al_types.h	2005-11-17 14:14:53.000000000 +0100
+++ openal.w/linux/src/al_types.h	2005-11-24 14:13:14.960573216 +0100
@@ -291,6 +291,7 @@
 	ALenum format;
 	ALuint speed;
 	ALuint bufsiz;
+	ALuint force_canon_speed;
 
 	DeviceEnum flags;
 	ALubyte *specifier;


More information about the Openal-devel mailing list