Mercurial > mplayer.hg
comparison libao2/ao_sun.c @ 29263:0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
author | diego |
---|---|
date | Wed, 13 May 2009 02:58:57 +0000 |
parents | 9a5b8c2ed6de |
children | 32725ca88fed |
comparison
equal
deleted
inserted
replaced
29262:7d545a6b8aff | 29263:0f1b5b68af32 |
---|---|
47 #include "audio_out_internal.h" | 47 #include "audio_out_internal.h" |
48 #include "libaf/af_format.h" | 48 #include "libaf/af_format.h" |
49 #include "mp_msg.h" | 49 #include "mp_msg.h" |
50 #include "help_mp.h" | 50 #include "help_mp.h" |
51 | 51 |
52 static const ao_info_t info = | 52 static const ao_info_t info = |
53 { | 53 { |
54 "Sun audio output", | 54 "Sun audio output", |
55 "sun", | 55 "sun", |
56 "Juergen Keil", | 56 "Juergen Keil", |
57 "" | 57 "" |
140 * "write" below. | 140 * "write" below. |
141 */ | 141 */ |
142 silence = calloc(1, len); | 142 silence = calloc(1, len); |
143 if (silence == NULL) | 143 if (silence == NULL) |
144 goto error; | 144 goto error; |
145 | 145 |
146 if ((fd = open(dev, O_WRONLY)) < 0) | 146 if ((fd = open(dev, O_WRONLY)) < 0) |
147 goto error; | 147 goto error; |
148 | 148 |
149 AUDIO_INITINFO(&info); | 149 AUDIO_INITINFO(&info); |
150 info.play.sample_rate = 44100; | 150 info.play.sample_rate = 44100; |
155 if (ioctl(fd, AUDIO_SETINFO, &info)) { | 155 if (ioctl(fd, AUDIO_SETINFO, &info)) { |
156 if ( mp_msg_test(MSGT_AO,MSGL_V) ) | 156 if ( mp_msg_test(MSGT_AO,MSGL_V) ) |
157 mp_msg(MSGT_AO, MSGL_ERR, MSGTR_AO_SUN_RtscSetinfoFailed); | 157 mp_msg(MSGT_AO, MSGL_ERR, MSGTR_AO_SUN_RtscSetinfoFailed); |
158 goto error; | 158 goto error; |
159 } | 159 } |
160 | 160 |
161 if (write(fd, silence, len) != len) { | 161 if (write(fd, silence, len) != len) { |
162 if ( mp_msg_test(MSGT_AO,MSGL_V) ) | 162 if ( mp_msg_test(MSGT_AO,MSGL_V) ) |
163 mp_msg(MSGT_AO, MSGL_ERR, MSGTR_AO_SUN_RtscWriteFailed); | 163 mp_msg(MSGT_AO, MSGL_ERR, MSGTR_AO_SUN_RtscWriteFailed); |
164 goto error; | 164 goto error; |
165 } | 165 } |
213 * For 44.1kkz, stereo, 16-bit format we would send sound data in 16kbytes | 213 * For 44.1kkz, stereo, 16-bit format we would send sound data in 16kbytes |
214 * chunks (== 4096 samples) to the audio device. If we see a minimum | 214 * chunks (== 4096 samples) to the audio device. If we see a minimum |
215 * sample counter increment from the soundcard driver of less than | 215 * sample counter increment from the soundcard driver of less than |
216 * 2000 samples, we assume that the driver provides a useable realtime | 216 * 2000 samples, we assume that the driver provides a useable realtime |
217 * sample counter in the AUDIO_INFO play.samples field. Timing based | 217 * sample counter in the AUDIO_INFO play.samples field. Timing based |
218 * on sample counts should be much more accurate than counting whole | 218 * on sample counts should be much more accurate than counting whole |
219 * 16kbyte chunks. | 219 * 16kbyte chunks. |
220 */ | 220 */ |
221 if (min_increment < 2000) | 221 if (min_increment < 2000) |
222 rtsc_ok = RTSC_ENABLED; | 222 rtsc_ok = RTSC_ENABLED; |
223 | 223 |
224 if ( mp_msg_test(MSGT_AO,MSGL_V) ) | 224 if ( mp_msg_test(MSGT_AO,MSGL_V) ) |
225 mp_msg(MSGT_AO,MSGL_V,"ao_sun: minimum sample counter increment per 10msec interval: %d\n" | 225 mp_msg(MSGT_AO,MSGL_V,"ao_sun: minimum sample counter increment per 10msec interval: %d\n" |
226 "\t%susing sample counter based timing code\n", | 226 "\t%susing sample counter based timing code\n", |
227 min_increment, rtsc_ok == RTSC_ENABLED ? "" : "not "); | 227 min_increment, rtsc_ok == RTSC_ENABLED ? "" : "not "); |
228 | 228 |
229 | 229 |
230 error: | 230 error: |
231 if (silence != NULL) free(silence); | 231 if (silence != NULL) free(silence); |
232 if (fd >= 0) { | 232 if (fd >= 0) { |
233 // remove the 0 bytes from the above measurement from the | 233 // remove the 0 bytes from the above measurement from the |
270 free(sr); | 270 free(sr); |
271 } | 271 } |
272 | 272 |
273 if (sr->flags & MIXER_SR_LIMITS) { | 273 if (sr->flags & MIXER_SR_LIMITS) { |
274 /* | 274 /* |
275 * HW can playback any rate between | 275 * HW can playback any rate between |
276 * sr->samp_rates[0] .. sr->samp_rates[1] | 276 * sr->samp_rates[0] .. sr->samp_rates[1] |
277 */ | 277 */ |
278 free(sr); | 278 free(sr); |
279 return 0; | 279 return 0; |
280 } else { | 280 } else { |
316 }; | 316 }; |
317 | 317 |
318 for (i = 0; audiocs_rates[i]; i++) { | 318 for (i = 0; audiocs_rates[i]; i++) { |
319 err = abs(audiocs_rates[i] - sample_rate); | 319 err = abs(audiocs_rates[i] - sample_rate); |
320 if (err == 0) { | 320 if (err == 0) { |
321 /* | 321 /* |
322 * exact supported sample rate match, no need to | 322 * exact supported sample rate match, no need to |
323 * retry something elise | 323 * retry something elise |
324 */ | 324 */ |
325 return 0; | 325 return 0; |
326 } | 326 } |
359 free(sr); | 359 free(sr); |
360 } | 360 } |
361 | 361 |
362 if (sr->flags & MIXER_SR_LIMITS) { | 362 if (sr->flags & MIXER_SR_LIMITS) { |
363 /* | 363 /* |
364 * HW can playback any rate between | 364 * HW can playback any rate between |
365 * sr->samp_rates[0] .. sr->samp_rates[1] | 365 * sr->samp_rates[0] .. sr->samp_rates[1] |
366 */ | 366 */ |
367 max_rate = sr->samp_rates[1]; | 367 max_rate = sr->samp_rates[1]; |
368 } else { | 368 } else { |
369 /* HW supports fixed sample rates only */ | 369 /* HW supports fixed sample rates only */ |
433 / AUDIO_MID_BALANCE; | 433 / AUDIO_MID_BALANCE; |
434 vol->right = volume; | 434 vol->right = volume; |
435 } | 435 } |
436 close( fd ); | 436 close( fd ); |
437 return CONTROL_OK; | 437 return CONTROL_OK; |
438 } | 438 } |
439 return CONTROL_ERROR; | 439 return CONTROL_ERROR; |
440 } | 440 } |
441 case AOCONTROL_SET_VOLUME: | 441 case AOCONTROL_SET_VOLUME: |
442 { | 442 { |
443 ao_control_vol_t *vol = (ao_control_vol_t *)arg; | 443 ao_control_vol_t *vol = (ao_control_vol_t *)arg; |
464 info.output_muted = (volume == 0); | 464 info.output_muted = (volume == 0); |
465 #endif | 465 #endif |
466 ioctl( fd,AUDIO_SETINFO,&info ); | 466 ioctl( fd,AUDIO_SETINFO,&info ); |
467 close( fd ); | 467 close( fd ); |
468 return CONTROL_OK; | 468 return CONTROL_OK; |
469 } | 469 } |
470 return CONTROL_ERROR; | 470 return CONTROL_ERROR; |
471 } | 471 } |
472 } | 472 } |
473 return CONTROL_UNKNOWN; | 473 return CONTROL_UNKNOWN; |
474 } | 474 } |
514 | 514 |
515 convert_u8_s8 = 0; | 515 convert_u8_s8 = 0; |
516 | 516 |
517 if (pass & 1) { | 517 if (pass & 1) { |
518 /* | 518 /* |
519 * on some sun audio drivers, 8-bit unsigned LINEAR8 encoding is | 519 * on some sun audio drivers, 8-bit unsigned LINEAR8 encoding is |
520 * not supported, but 8-bit signed encoding is. | 520 * not supported, but 8-bit signed encoding is. |
521 * | 521 * |
522 * Try S8, and if it works, use our own U8->S8 conversion before | 522 * Try S8, and if it works, use our own U8->S8 conversion before |
523 * sending the samples to the sound driver. | 523 * sending the samples to the sound driver. |
524 */ | 524 */ |
537 * | 537 * |
538 * In case the requested sample rate is very close to one of the | 538 * In case the requested sample rate is very close to one of the |
539 * supported rates, use the fixed supported rate instead. | 539 * supported rates, use the fixed supported rate instead. |
540 */ | 540 */ |
541 if (!(info.play.sample_rate = | 541 if (!(info.play.sample_rate = |
542 find_close_samplerate_match(audio_fd, rate))) | 542 find_close_samplerate_match(audio_fd, rate))) |
543 continue; | 543 continue; |
544 | 544 |
545 /* | 545 /* |
546 * I'm not returning the correct sample rate in | 546 * I'm not returning the correct sample rate in |
547 * |ao_data.samplerate|, to avoid software resampling. | 547 * |ao_data.samplerate|, to avoid software resampling. |