From 7a6d1acd7c2c997800c575f396ef07474d3f7e5a Mon Sep 17 00:00:00 2001 From: mswitch Date: Wed, 19 Dec 2001 14:31:31 +0000 Subject: [PATCH] Remove lame upsampler, cleaned out stuff relating to setting channels. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@3616 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libao2/ao_dxr3.c | 65 ++++++++++++------------------------------------ 1 file changed, 16 insertions(+), 49 deletions(-) diff --git a/libao2/ao_dxr3.c b/libao2/ao_dxr3.c index 711f5367af..6522c578f8 100644 --- a/libao2/ao_dxr3.c +++ b/libao2/ao_dxr3.c @@ -81,11 +81,21 @@ static int init(int rate,int channels,int format,int flags) printf("AO: [dxr3] Sample format: %s (requested: %s)\n", audio_out_format_name(ao_data.format), audio_out_format_name(format)); - ao_data.channels=channels-1; - if( ioctl (fd_audio, SNDCTL_DSP_STEREO, &ao_data.channels) < 0 ) - printf( "AO: [dxr3] Unable to set number of channels\n" ); + ao_data.channels=channels; + if(format != AFMT_AC3) + if(channels>2) + if( ioctl (fd_audio, SNDCTL_DSP_CHANNELS, &ao_data.channels) < 0 ) + printf( "AO: [dxr3] Unable to set number of channels\n" ); + else + { + int c = channels-1; + if( ioctl(fd_audio,SNDCTL_DSP_STEREO,&c) < 0) + printf( "AO: [dxr3] Unable to set number of channels for AC3\n" ); + } - ao_data.bps = (channels+1)*rate; + ao_data.bps = channels*rate; + if(format != AFMT_U8 && format != AFMT_S8) + ao_data.bps*=2; ao_data.samplerate=rate; if( ioctl (fd_audio, SNDCTL_DSP_SPEED, &ao_data.samplerate) < 0 ) { @@ -105,7 +115,6 @@ static int init(int rate,int channels,int format,int flags) ao_data.samplerate = rate; } else printf("AO: [dxr3] Using %d Hz samplerate (requested: %d)\n",ao_data.samplerate,rate); - if(format == AFMT_AC3 ) ao_data.bps *= 2; if( ioctl(fd_audio, SNDCTL_DSP_GETOSPACE, &dxr3_buf_info)==-1 ) { @@ -207,50 +216,8 @@ static int get_space() // return: number of bytes played static int play(void* data,int len,int flags) { - 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