Mercurial > mplayer.hg
comparison libao2/ao_sun.c @ 1807:6da3b9428ff0
Sun audiocs HW does not support AFMT_U8, try to use AFMT_S8 instead. If AFMT_S8
is available, convert to AFMT_S8 in software.
author | jkeil |
---|---|
date | Fri, 31 Aug 2001 20:34:17 +0000 |
parents | 8c57a5a3c645 |
children | 981a9e5118ce |
comparison
equal
deleted
inserted
replaced
1806:44d4f1e9afb0 | 1807:6da3b9428ff0 |
---|---|
52 | 52 |
53 static char *audio_dev = "/dev/audio"; | 53 static char *audio_dev = "/dev/audio"; |
54 static int queued_bursts = 0; | 54 static int queued_bursts = 0; |
55 static int queued_samples = 0; | 55 static int queued_samples = 0; |
56 static int bytes_per_sample = 0; | 56 static int bytes_per_sample = 0; |
57 static int convert_u8_s8; | |
57 static int audio_fd = -1; | 58 static int audio_fd = -1; |
58 static enum { | 59 static enum { |
59 RTSC_UNKNOWN = 0, | 60 RTSC_UNKNOWN = 0, |
60 RTSC_ENABLED, | 61 RTSC_ENABLED, |
61 RTSC_DISABLED | 62 RTSC_DISABLED |
228 // return: 1=success 0=fail | 229 // return: 1=success 0=fail |
229 static int init(int rate,int channels,int format,int flags){ | 230 static int init(int rate,int channels,int format,int flags){ |
230 | 231 |
231 audio_info_t info; | 232 audio_info_t info; |
232 int byte_per_sec; | 233 int byte_per_sec; |
234 int ok; | |
233 | 235 |
234 if (ao_subdevice) audio_dev = ao_subdevice; | 236 if (ao_subdevice) audio_dev = ao_subdevice; |
235 | 237 |
236 if (enable_sample_timing == RTSC_UNKNOWN | 238 if (enable_sample_timing == RTSC_UNKNOWN |
237 && !getenv("AO_SUN_DISABLE_SAMPLE_TIMING")) { | 239 && !getenv("AO_SUN_DISABLE_SAMPLE_TIMING")) { |
255 (format==AFMT_S16_LE || format==AFMT_S16_BE | 257 (format==AFMT_S16_LE || format==AFMT_S16_BE |
256 ? AUDIO_PRECISION_16 | 258 ? AUDIO_PRECISION_16 |
257 : AUDIO_PRECISION_8); | 259 : AUDIO_PRECISION_8); |
258 info.play.channels = ao_channels = channels; | 260 info.play.channels = ao_channels = channels; |
259 info.play.sample_rate = ao_samplerate = rate; | 261 info.play.sample_rate = ao_samplerate = rate; |
260 if(ioctl (audio_fd, AUDIO_SETINFO, &info)<0) | 262 convert_u8_s8 = 0; |
263 ok = ioctl(audio_fd, AUDIO_SETINFO, &info) >= 0; | |
264 if (!ok && info.play.encoding == AUDIO_ENCODING_LINEAR8) { | |
265 /* sun audiocs hardware does not support U8 format, try S8... */ | |
266 info.play.encoding = AUDIO_ENCODING_LINEAR; | |
267 ok = ioctl(audio_fd, AUDIO_SETINFO, &info) >= 0; | |
268 if (ok) { | |
269 /* we must perform software U8 -> S8 conversion */ | |
270 convert_u8_s8 = 1; | |
271 } | |
272 } | |
273 if (!ok) { | |
261 printf("audio_setup: your card doesn't support %d channel, %s, %d Hz samplerate\n", | 274 printf("audio_setup: your card doesn't support %d channel, %s, %d Hz samplerate\n", |
262 channels, audio_out_format_name(format), rate); | 275 channels, audio_out_format_name(format), rate); |
276 return 0; | |
277 } | |
278 | |
263 bytes_per_sample = channels * info.play.precision / 8; | 279 bytes_per_sample = channels * info.play.precision / 8; |
264 byte_per_sec = bytes_per_sample * rate; | 280 byte_per_sec = bytes_per_sample * rate; |
265 ao_outburst = byte_per_sec > 100000 ? 16384 : 8192; | 281 ao_outburst = byte_per_sec > 100000 ? 16384 : 8192; |
266 | 282 |
267 #ifdef __not_used__ | 283 #ifdef __not_used__ |
422 swab_len = len; | 438 swab_len = len; |
423 if (swab_buf == NULL) return 0; | 439 if (swab_buf == NULL) return 0; |
424 } | 440 } |
425 swab(data, swab_buf, len); | 441 swab(data, swab_buf, len); |
426 data = swab_buf; | 442 data = swab_buf; |
443 } else if (ao_format == AFMT_U8 && convert_u8_s8) { | |
444 int i; | |
445 unsigned char *p = data; | |
446 | |
447 for (i = 0, p = data; i < len; i++, p++) | |
448 *p ^= 0x80; | |
427 } | 449 } |
428 | 450 |
429 len = write(audio_fd, data, len); | 451 len = write(audio_fd, data, len); |
430 if(len > 0) { | 452 if(len > 0) { |
431 queued_samples += len / bytes_per_sample; | 453 queued_samples += len / bytes_per_sample; |