Mercurial > mplayer.hg
comparison libao2/ao_dxr3.c @ 3615:2a75bbac913e
Remove lame upsampler, cleaned out stuff relating to setting channels.
author | mswitch |
---|---|
date | Wed, 19 Dec 2001 14:31:31 +0000 |
parents | f8bfaa1c9487 |
children | a515ff1954fd |
comparison
equal
deleted
inserted
replaced
3614:6fef049b8fe4 | 3615:2a75bbac913e |
---|---|
79 } | 79 } |
80 | 80 |
81 printf("AO: [dxr3] Sample format: %s (requested: %s)\n", | 81 printf("AO: [dxr3] Sample format: %s (requested: %s)\n", |
82 audio_out_format_name(ao_data.format), audio_out_format_name(format)); | 82 audio_out_format_name(ao_data.format), audio_out_format_name(format)); |
83 | 83 |
84 ao_data.channels=channels-1; | 84 ao_data.channels=channels; |
85 if( ioctl (fd_audio, SNDCTL_DSP_STEREO, &ao_data.channels) < 0 ) | 85 if(format != AFMT_AC3) |
86 printf( "AO: [dxr3] Unable to set number of channels\n" ); | 86 if(channels>2) |
87 if( ioctl (fd_audio, SNDCTL_DSP_CHANNELS, &ao_data.channels) < 0 ) | |
88 printf( "AO: [dxr3] Unable to set number of channels\n" ); | |
89 else | |
90 { | |
91 int c = channels-1; | |
92 if( ioctl(fd_audio,SNDCTL_DSP_STEREO,&c) < 0) | |
93 printf( "AO: [dxr3] Unable to set number of channels for AC3\n" ); | |
94 } | |
87 | 95 |
88 ao_data.bps = (channels+1)*rate; | 96 ao_data.bps = channels*rate; |
97 if(format != AFMT_U8 && format != AFMT_S8) | |
98 ao_data.bps*=2; | |
89 ao_data.samplerate=rate; | 99 ao_data.samplerate=rate; |
90 if( ioctl (fd_audio, SNDCTL_DSP_SPEED, &ao_data.samplerate) < 0 ) | 100 if( ioctl (fd_audio, SNDCTL_DSP_SPEED, &ao_data.samplerate) < 0 ) |
91 { | 101 { |
92 printf( "AO: [dxr3] Unable to set samplerate\n" ); | 102 printf( "AO: [dxr3] Unable to set samplerate\n" ); |
93 return 0; | 103 return 0; |
103 } | 113 } |
104 printf("AO: [dxr3] Using %d Hz samplerate (requested: %d) (Upsampling)\n",ao_data.samplerate,rate); | 114 printf("AO: [dxr3] Using %d Hz samplerate (requested: %d) (Upsampling)\n",ao_data.samplerate,rate); |
105 ao_data.samplerate = rate; | 115 ao_data.samplerate = rate; |
106 } | 116 } |
107 else printf("AO: [dxr3] Using %d Hz samplerate (requested: %d)\n",ao_data.samplerate,rate); | 117 else printf("AO: [dxr3] Using %d Hz samplerate (requested: %d)\n",ao_data.samplerate,rate); |
108 if(format == AFMT_AC3 ) ao_data.bps *= 2; | |
109 | 118 |
110 if( ioctl(fd_audio, SNDCTL_DSP_GETOSPACE, &dxr3_buf_info)==-1 ) | 119 if( ioctl(fd_audio, SNDCTL_DSP_GETOSPACE, &dxr3_buf_info)==-1 ) |
111 { | 120 { |
112 int r=0; | 121 int r=0; |
113 printf("AO: [dxr3] Driver doesn't support SNDCTL_DSP_GETOSPACE :-(\n"); | 122 printf("AO: [dxr3] Driver doesn't support SNDCTL_DSP_GETOSPACE :-(\n"); |
205 // playes 'len' bytes of 'data' | 214 // playes 'len' bytes of 'data' |
206 // upsamples if samplerate < 44100 | 215 // upsamples if samplerate < 44100 |
207 // return: number of bytes played | 216 // return: number of bytes played |
208 static int play(void* data,int len,int flags) | 217 static int play(void* data,int len,int flags) |
209 { | 218 { |
210 if( ao_data.samplerate < 44100 ) | 219 len /= ao_data.outburst; |
211 { | 220 return write(fd_audio,data,len*ao_data.outburst); |
212 int i,j,ratio,len2; | |
213 unsigned char *data2,*s,*d; | |
214 | |
215 ratio = 44100/ao_data.samplerate;ratio/=2;ratio*=2; | |
216 len2 = len * ratio; | |
217 data2 = malloc(len2); | |
218 | |
219 s = data; | |
220 d = data2; | |
221 | |
222 //Upsampler | |
223 if( ao_data.format == AFMT_U8 ) | |
224 { | |
225 for(i=0;i<ratio/2;i++) | |
226 for(j=0;j<len;j++) | |
227 { | |
228 *d = *s; | |
229 d++; | |
230 *d = *s; | |
231 d++;s++; | |
232 } | |
233 } | |
234 else | |
235 { | |
236 for(i=0;i<ratio/2;i++) | |
237 for(j=0;j<len/2;j++) | |
238 { | |
239 *d = *s; | |
240 d++;s++; | |
241 *d = *s; | |
242 d++;s--; | |
243 *d = *s; | |
244 d++;s++; | |
245 *d = *s; | |
246 d++;s++; | |
247 } | |
248 } | |
249 if( len2 < 0 ) return 0; | |
250 write(fd_audio,data2,len2); | |
251 return len; | |
252 } | |
253 return write(fd_audio,data,len); | |
254 } | 221 } |
255 | 222 |
256 // return: delay in seconds between first and last sample in buffer | 223 // return: delay in seconds between first and last sample in buffer |
257 static float get_delay() | 224 static float get_delay() |
258 { | 225 { |