mirror of
https://github.com/mpv-player/mpv
synced 2025-01-28 10:33:20 +00:00
updated for libaf rules
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@7659 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
parent
f12673921c
commit
24d0b8f5e1
@ -84,13 +84,33 @@ static int init(int rate,int channels,int format,int flags){
|
|||||||
/* bits is only equal to format if (format == 8) or (format == 16);
|
/* bits is only equal to format if (format == 8) or (format == 16);
|
||||||
this means that the following "if" is a kludge and should
|
this means that the following "if" is a kludge and should
|
||||||
really be a switch to be correct in all cases */
|
really be a switch to be correct in all cases */
|
||||||
if (format == AFMT_S16_BE) { bits = 16; }
|
|
||||||
else { bits = format; }
|
|
||||||
|
|
||||||
wavhdr.channels = le2me_16(channels);
|
bits=8;
|
||||||
wavhdr.sample_rate = le2me_32(rate);
|
switch(format){
|
||||||
wavhdr.bytes_per_second = rate * (bits / 8) * channels;
|
case AFMT_S8:
|
||||||
wavhdr.bytes_per_second = le2me_32(wavhdr.bytes_per_second);
|
format=AFMT_U8;
|
||||||
|
case AFMT_U8:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
#ifdef WORDS_BIGENDIAN
|
||||||
|
format=AFMT_S16_BE;
|
||||||
|
#else
|
||||||
|
format=AFMT_S16_LE;
|
||||||
|
#endif
|
||||||
|
bits=16;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
ao_data.outburst = 65536;
|
||||||
|
ao_data.buffersize= 2*65536;
|
||||||
|
ao_data.channels=channels;
|
||||||
|
ao_data.samplerate=rate;
|
||||||
|
ao_data.format=format;
|
||||||
|
ao_data.bps=channels*rate*(bits/8);
|
||||||
|
|
||||||
|
wavhdr.channels = le2me_16(ao_data.channels);
|
||||||
|
wavhdr.sample_rate = le2me_32(ao_data.samplerate);
|
||||||
|
wavhdr.bytes_per_second = le2me_32(ao_data.bps);
|
||||||
wavhdr.bits = le2me_16(bits);
|
wavhdr.bits = le2me_16(bits);
|
||||||
|
|
||||||
printf("PCM: File: %s (%s)\n"
|
printf("PCM: File: %s (%s)\n"
|
||||||
@ -102,10 +122,6 @@ static int init(int rate,int channels,int format,int flags){
|
|||||||
"for RAW PCM -nowaveheader.\n");
|
"for RAW PCM -nowaveheader.\n");
|
||||||
|
|
||||||
fp = fopen(ao_outputfilename, "wb");
|
fp = fopen(ao_outputfilename, "wb");
|
||||||
|
|
||||||
ao_data.outburst = 65536;
|
|
||||||
|
|
||||||
|
|
||||||
if(fp) {
|
if(fp) {
|
||||||
if(ao_pcm_waveheader) /* Reserve space for wave header */
|
if(ao_pcm_waveheader) /* Reserve space for wave header */
|
||||||
fwrite(&wavhdr,sizeof(wavhdr),1,fp);
|
fwrite(&wavhdr,sizeof(wavhdr),1,fp);
|
||||||
@ -158,16 +174,16 @@ static int get_space(){
|
|||||||
// return: number of bytes played
|
// return: number of bytes played
|
||||||
static int play(void* data,int len,int flags){
|
static int play(void* data,int len,int flags){
|
||||||
|
|
||||||
#ifdef WORDS_BIGENDIAN
|
// let libaf to do the conversion...
|
||||||
register int i;
|
#if 0
|
||||||
unsigned short *buffer = (unsigned short *) data;
|
//#ifdef WORDS_BIGENDIAN
|
||||||
|
if (ao_data.format == AFMT_S16_LE) {
|
||||||
if (wavhdr.bits == le2me_16(16)) {
|
unsigned short *buffer = (unsigned short *) data;
|
||||||
|
register int i;
|
||||||
for(i = 0; i < len/2; ++i) {
|
for(i = 0; i < len/2; ++i) {
|
||||||
buffer[i] = le2me_16(buffer[i]);
|
buffer[i] = le2me_16(buffer[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* FIXME: take care of cases with more than 8 bits here? */
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//printf("PCM: Writing chunk!\n");
|
//printf("PCM: Writing chunk!\n");
|
||||||
|
Loading…
Reference in New Issue
Block a user