# HG changeset patch # User mswitch # Date 1007158731 0 # Node ID 4bc4354ec88e5b6fc460a652392176a9b703815e # Parent 697c115d7d7964d0d67ef5eb8a9237883440002b Added support for upsampling since dxr3/h+ only supports 44100Hz and 48000Hz, currently it only works on 44100/(2*ratio) Reverted get_delay to return a properly calculated value instead of 0.0 diff -r 697c115d7d79 -r 4bc4354ec88e libao2/ao_dxr3.c --- a/libao2/ao_dxr3.c Fri Nov 30 22:18:34 2001 +0000 +++ b/libao2/ao_dxr3.c Fri Nov 30 22:18:51 2001 +0000 @@ -86,12 +86,26 @@ if( ioctl (fd_audio, SNDCTL_DSP_STEREO, &ao_data.channels) < 0 ) printf( "AO: [dxr3] Unable to set number of channels\n" ); - // set rate ao_data.bps = (channels+1)*rate; ao_data.samplerate=rate; if( ioctl (fd_audio, SNDCTL_DSP_SPEED, &ao_data.samplerate) < 0 ) + { printf( "AO: [dxr3] Unable to set samplerate\n" ); - printf("AO: [dxr3] Using %d Hz samplerate (requested: %d)\n",ao_data.samplerate,rate); + return 0; + } + if( rate < ao_data.samplerate ) + { + ao_data.samplerate = 44100; + ioctl(fd_audio, SNDCTL_DSP_SPEED, &ao_data.samplerate); + if( ao_data.samplerate != 44100 ) + { + printf( "AO: [dxr3] Unable to set samplerate\n" ); + return 0; + } + printf("AO: [dxr3] Using %d Hz samplerate (requested: %d) (Upsampling)\n",ao_data.samplerate,rate); + ao_data.samplerate = rate; + } + else printf("AO: [dxr3] Using %d Hz samplerate (requested: %d)\n",ao_data.samplerate,rate); } else ao_data.bps *= 2; @@ -190,23 +204,68 @@ return space; } +// playes 'len' bytes of 'data' +// upsamples if samplerate < 44100 +// return: number of bytes played static int play(void* data,int len,int flags) { if( ioctl( fd_audio, EM8300_IOCTL_AUDIO_SETPTS, &ao_data.pts ) < 0 ) printf( "AO: [dxr3] Unable to set PTS\n" ); + if( ao_data.samplerate < 44100 ) + { + int i,j,ratio,len2; + unsigned char *data2,*s,*d; + + ratio = 44100/ao_data.samplerate;ratio/=2;ratio*=2; + len2 = len * ratio; + data2 = malloc(len2); + + s = data; + d = data2; + + //Upsampler + if( ao_data.format == AFMT_U8 ) + { + for(i=0;i