From facc11e9560017ebc9c8c7d52e7480b28a8e8381 Mon Sep 17 00:00:00 2001 From: angel Date: Sun, 5 Oct 2003 18:58:25 +0000 Subject: [PATCH] SGI output driver finally works. git-svn-id: file:///home/angel/tmp/svn-triptico/ahxm/trunk@14 c87de0a0-a11c-0410-a1e5-866214bc28b2 --- out_sgi.c | 38 +++++++++++++++++++++++++++++--------- 1 file changed, 29 insertions(+), 9 deletions(-) diff --git a/out_sgi.c b/out_sgi.c index 289c4c2..04980c0 100644 --- a/out_sgi.c +++ b/out_sgi.c @@ -39,6 +39,14 @@ static ALconfig ac; /* audio port */ static ALport ap; +/* handmade buffering */ +#ifndef BUFFER_SIZE +#define BUFFER_SIZE 65536 +#endif + +static short _buffer[BUFFER_SIZE]; +static int _bindex=0; + /******************* Code @@ -46,11 +54,12 @@ static ALport ap; int _out_open_sgi(char * file) { + ALpv p[1]; + ac=alNewConfig(); if(!ac) return(-100); - /* set stereo, 16 bit, signed */ if(alSetChannels(ac, AL_STEREO)==-1) return(-101); @@ -60,12 +69,21 @@ int _out_open_sgi(char * file) if(alSetSampFmt(ac, AL_SAMPFMT_TWOSCOMP)==-1) return(-103); - if(alSetDevice(ac, AL_DEFAULT_OUTPUT)==-1) + if(alSetQueueSize(ac, 131069)==-1) return(-104); + if(alSetDevice(ac, AL_DEFAULT_OUTPUT)==-1) + return(-105); + + p[0].param=AL_OUTPUT_RATE; + p[0].value.ll=alDoubleToFixed((double)_frequency); + + if(alSetParams(alGetDevice(ac), p, 1)==-1) + return(-106); + ap=alOpenPort("Ann Hell", "w", ac); - if(!ap) return(-105); + if(!ap) return(-107); return(0); } @@ -73,12 +91,14 @@ int _out_open_sgi(char * file) int _out_write_sgi(int lsample, int rsample) { - short buf[2]; - - buf[0]=(short) lsample; - buf[1]=(short) rsample; - - alWriteFrames(ap, buf, 2); + _buffer[_bindex++]=(short)lsample; + _buffer[_bindex++]=(short)rsample; + + if(_bindex==BUFFER_SIZE) + { + alWriteFrames(ap, _buffer, BUFFER_SIZE / 2); + _bindex=0; + } return(0); } -- 2.11.4.GIT