Mercurial > mplayer.hg
comparison libao2/ao_sun.c @ 14247:7ea3c86f3295
10l
author | alex |
---|---|
date | Mon, 27 Dec 2004 17:49:52 +0000 |
parents | a92101a7eb49 |
children | 8f59f661f317 |
comparison
equal
deleted
inserted
replaced
14246:474a40917f73 | 14247:7ea3c86f3295 |
---|---|
23 #include "config.h" | 23 #include "config.h" |
24 #include "mixer.h" | 24 #include "mixer.h" |
25 | 25 |
26 #include "audio_out.h" | 26 #include "audio_out.h" |
27 #include "audio_out_internal.h" | 27 #include "audio_out_internal.h" |
28 #include "afmt.h" | 28 #include "libaf/af_format.h" |
29 #include "mp_msg.h" | 29 #include "mp_msg.h" |
30 #include "help_mp.h" | 30 #include "help_mp.h" |
31 | 31 |
32 static ao_info_t info = | 32 static ao_info_t info = |
33 { | 33 { |
67 | 67 |
68 extern int verbose; | 68 extern int verbose; |
69 | 69 |
70 | 70 |
71 // convert an OSS audio format specification into a sun audio encoding | 71 // convert an OSS audio format specification into a sun audio encoding |
72 static int oss2sunfmt(int oss_format) | 72 static int af2sunfmt(int format) |
73 { | 73 { |
74 switch (oss_format){ | 74 switch (format){ |
75 case AFMT_MU_LAW: | 75 case AF_FORMAT_MU_LAW: |
76 return AUDIO_ENCODING_ULAW; | 76 return AUDIO_ENCODING_ULAW; |
77 case AFMT_A_LAW: | 77 case AF_FORMAT_A_LAW: |
78 return AUDIO_ENCODING_ALAW; | 78 return AUDIO_ENCODING_ALAW; |
79 case AFMT_S16_BE: | 79 case AF_FORMAT_S16_BE: |
80 case AFMT_S16_LE: | 80 case AF_FORMAT_S16_LE: |
81 return AUDIO_ENCODING_LINEAR; | 81 return AUDIO_ENCODING_LINEAR; |
82 #ifdef AUDIO_ENCODING_LINEAR8 // Missing on SunOS 5.5.1... | 82 #ifdef AUDIO_ENCODING_LINEAR8 // Missing on SunOS 5.5.1... |
83 case AFMT_U8: | 83 case AF_FORMAT_U8: |
84 return AUDIO_ENCODING_LINEAR8; | 84 return AUDIO_ENCODING_LINEAR8; |
85 #endif | 85 #endif |
86 #ifdef AUDIO_ENCODING_DVI // Missing on NetBSD... | 86 #ifdef AUDIO_ENCODING_DVI // Missing on NetBSD... |
87 case AFMT_IMA_ADPCM: | 87 case AF_FORMAT_IMA_ADPCM: |
88 return AUDIO_ENCODING_DVI; | 88 return AUDIO_ENCODING_DVI; |
89 #endif | 89 #endif |
90 default: | 90 default: |
91 return AUDIO_ENCODING_NONE; | 91 return AUDIO_ENCODING_NONE; |
92 } | 92 } |
463 if (enable_sample_timing == RTSC_UNKNOWN | 463 if (enable_sample_timing == RTSC_UNKNOWN |
464 && !getenv("AO_SUN_DISABLE_SAMPLE_TIMING")) { | 464 && !getenv("AO_SUN_DISABLE_SAMPLE_TIMING")) { |
465 enable_sample_timing = realtime_samplecounter_available(audio_dev); | 465 enable_sample_timing = realtime_samplecounter_available(audio_dev); |
466 } | 466 } |
467 | 467 |
468 #define AF_FILTER_TEST 0 | |
469 #if AF_FILTER_TEST | |
470 /* test code to force use of the audio filter modules */ | |
471 { | |
472 char *s; | |
473 if (s = getenv("AF_RATE")) | |
474 rate = atoi(s); | |
475 if (s = getenv("AF_CHANNELS")) | |
476 channels = atoi(s); | |
477 if (s = getenv("AF_BITS")) | |
478 format = atoi(s) == 16 ? AFMT_S16_NE : AFMT_U8; | |
479 } | |
480 #endif | |
481 | |
482 // printf("ao2: %d Hz %d chans %s [0x%X]\n", | 468 // printf("ao2: %d Hz %d chans %s [0x%X]\n", |
483 // rate,channels,audio_out_format_name(format),format); | 469 // rate,channels,audio_out_format_name(format),format); |
484 | 470 |
485 audio_fd=open(audio_dev, O_WRONLY); | 471 audio_fd=open(audio_dev, O_WRONLY); |
486 if(audio_fd<0){ | 472 if(audio_fd<0){ |
493 for (ok = pass = 0; pass <= 5; pass++) { /* pass 6&7 not useful */ | 479 for (ok = pass = 0; pass <= 5; pass++) { /* pass 6&7 not useful */ |
494 | 480 |
495 AUDIO_INITINFO(&info); | 481 AUDIO_INITINFO(&info); |
496 info.play.encoding = oss2sunfmt(ao_data.format = format); | 482 info.play.encoding = oss2sunfmt(ao_data.format = format); |
497 info.play.precision = | 483 info.play.precision = |
498 (format==AFMT_S16_LE || format==AFMT_S16_BE | 484 (format==AF_FORMAT_S16_LE || format==AF_FORMAT_S16_BE |
499 ? AUDIO_PRECISION_16 | 485 ? AUDIO_PRECISION_16 |
500 : AUDIO_PRECISION_8); | 486 : AUDIO_PRECISION_8); |
501 info.play.channels = ao_data.channels = channels; | 487 info.play.channels = ao_data.channels = channels; |
502 info.play.sample_rate = ao_data.samplerate = rate; | 488 info.play.sample_rate = ao_data.samplerate = rate; |
503 | 489 |
576 // Measuring buffer size: | 562 // Measuring buffer size: |
577 void* data; | 563 void* data; |
578 ao_data.buffersize=0; | 564 ao_data.buffersize=0; |
579 #ifdef HAVE_AUDIO_SELECT | 565 #ifdef HAVE_AUDIO_SELECT |
580 data = malloc(ao_data.outburst); | 566 data = malloc(ao_data.outburst); |
581 memset(data, format==AFMT_U8 ? 0x80 : 0, ao_data.outburst); | 567 memset(data, format==AF_FORMAT_U8 ? 0x80 : 0, ao_data.outburst); |
582 while(ao_data.buffersize<0x40000){ | 568 while(ao_data.buffersize<0x40000){ |
583 fd_set rfds; | 569 fd_set rfds; |
584 struct timeval tv; | 570 struct timeval tv; |
585 FD_ZERO(&rfds); FD_SET(audio_fd,&rfds); | 571 FD_ZERO(&rfds); FD_SET(audio_fd,&rfds); |
586 tv.tv_sec=0; tv.tv_usec = 0; | 572 tv.tv_sec=0; tv.tv_usec = 0; |
639 ioctl(audio_fd, AUDIO_DRAIN, 0); | 625 ioctl(audio_fd, AUDIO_DRAIN, 0); |
640 | 626 |
641 AUDIO_INITINFO(&info); | 627 AUDIO_INITINFO(&info); |
642 info.play.encoding = oss2sunfmt(ao_data.format); | 628 info.play.encoding = oss2sunfmt(ao_data.format); |
643 info.play.precision = | 629 info.play.precision = |
644 (ao_data.format==AFMT_S16_LE || ao_data.format==AFMT_S16_BE | 630 (ao_data.format==AF_FORMAT_S16_LE || ao_data.format==AF_FORMAT_S16_BE |
645 ? AUDIO_PRECISION_16 | 631 ? AUDIO_PRECISION_16 |
646 : AUDIO_PRECISION_8); | 632 : AUDIO_PRECISION_8); |
647 info.play.channels = ao_data.channels; | 633 info.play.channels = ao_data.channels; |
648 info.play.sample_rate = ao_data.samplerate; | 634 info.play.sample_rate = ao_data.samplerate; |
649 info.play.samples = 0; | 635 info.play.samples = 0; |
708 // plays 'len' bytes of 'data' | 694 // plays 'len' bytes of 'data' |
709 // it should round it down to outburst*n | 695 // it should round it down to outburst*n |
710 // return: number of bytes played | 696 // return: number of bytes played |
711 static int play(void* data,int len,int flags){ | 697 static int play(void* data,int len,int flags){ |
712 #if WORDS_BIGENDIAN | 698 #if WORDS_BIGENDIAN |
713 int native_endian = AFMT_S16_BE; | 699 int native_endian = AF_FORMAT_S16_BE; |
714 #else | 700 #else |
715 int native_endian = AFMT_S16_LE; | 701 int native_endian = AF_FORMAT_S16_LE; |
716 #endif | 702 #endif |
717 | 703 |
718 if (len < ao_data.outburst) return 0; | 704 if (len < ao_data.outburst) return 0; |
719 len /= ao_data.outburst; | 705 len /= ao_data.outburst; |
720 len *= ao_data.outburst; | 706 len *= ao_data.outburst; |
721 | 707 |
722 /* 16-bit format using the 'wrong' byteorder? swap words */ | 708 /* 16-bit format using the 'wrong' byteorder? swap words */ |
723 if ((ao_data.format == AFMT_S16_LE || ao_data.format == AFMT_S16_BE) | 709 if ((ao_data.format == AF_FORMAT_S16_LE || ao_data.format == AF_FORMAT_S16_BE) |
724 && ao_data.format != native_endian) { | 710 && ao_data.format != native_endian) { |
725 static void *swab_buf; | 711 static void *swab_buf; |
726 static int swab_len; | 712 static int swab_len; |
727 if (len > swab_len) { | 713 if (len > swab_len) { |
728 if (swab_buf) | 714 if (swab_buf) |
732 swab_len = len; | 718 swab_len = len; |
733 if (swab_buf == NULL) return 0; | 719 if (swab_buf == NULL) return 0; |
734 } | 720 } |
735 swab(data, swab_buf, len); | 721 swab(data, swab_buf, len); |
736 data = swab_buf; | 722 data = swab_buf; |
737 } else if (ao_data.format == AFMT_U8 && convert_u8_s8) { | 723 } else if (ao_data.format == AF_FORMAT_U8 && convert_u8_s8) { |
738 int i; | 724 int i; |
739 unsigned char *p = data; | 725 unsigned char *p = data; |
740 | 726 |
741 for (i = 0, p = data; i < len; i++, p++) | 727 for (i = 0, p = data; i < len; i++, p++) |
742 *p ^= 0x80; | 728 *p ^= 0x80; |