From 507121f7fe2d170dd8db99d3112602036ddef718 Mon Sep 17 00:00:00 2001 From: alex Date: Mon, 27 Dec 2004 17:30:15 +0000 Subject: removing AFMT_ dependancy git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@14246 b3059339-0415-0410-9bf9-f77b7e298cf2 --- Makefile | 2 +- libaf/Makefile | 2 +- libaf/af_comp.c | 2 +- libaf/af_equalizer.c | 4 +- libaf/af_export.c | 3 +- libaf/af_extrastereo.c | 2 +- libaf/af_format.c | 47 ++++++++++++----- libaf/af_format.h | 70 +++++++++++++++++++++---- libaf/af_gate.c | 2 +- libaf/af_hrtf.c | 2 +- libaf/af_lavcresample.c | 2 +- libaf/af_mp.c | 98 ---------------------------------- libaf/af_mp.h | 5 -- libaf/af_pan.c | 2 +- libaf/af_resample.c | 11 ++-- libaf/af_sub.c | 2 +- libaf/af_surround.c | 2 +- libaf/af_sweep.c | 2 +- libaf/af_volnorm.c | 10 ++-- libaf/af_volume.c | 10 ++-- libaf/config.h | 2 + libao2/Makefile | 2 +- libao2/afmt.c | 90 ------------------------------- libao2/afmt.h | 84 ----------------------------- libao2/ao_alsa.c | 32 +++++------ libao2/ao_alsa5.c | 18 +++---- libao2/ao_arts.c | 14 ++--- libao2/ao_dsound.c | 16 +++--- libao2/ao_dxr2.c | 7 ++- libao2/ao_esd.c | 10 ++-- libao2/ao_jack.c | 10 ++-- libao2/ao_macosx.c | 4 +- libao2/ao_mpegpes.c | 16 +++--- libao2/ao_nas.c | 18 +++---- libao2/ao_null.c | 4 +- libao2/ao_oss.c | 131 ++++++++++++++++++++++++++++++++++++++++------ libao2/ao_pcm.c | 16 +++--- libao2/ao_plugin.c | 6 +-- libao2/ao_polyp.c | 10 ++-- libao2/ao_sdl.c | 32 +++++------ libao2/ao_win32.c | 18 +++---- libao2/audio_out.c | 2 +- libao2/audio_plugin.h | 2 +- libao2/pl_delay.c | 4 +- libao2/pl_eq.c | 4 +- libao2/pl_extrastereo.c | 6 +-- libao2/pl_format.c | 59 +++++++++++---------- libao2/pl_resample.c | 4 +- libao2/pl_surround.c | 6 +-- libao2/pl_volnorm.c | 8 +-- libao2/pl_volume.c | 10 ++-- libmpcodecs/ad_dvdpcm.c | 10 ++-- libmpcodecs/ad_hwac3.c | 2 +- libmpcodecs/ad_internal.h | 2 +- libmpcodecs/ad_pcm.c | 30 +++++------ libmpcodecs/ad_ra1428.c | 2 +- libmpcodecs/ad_sample.c | 2 +- libmpcodecs/dec_audio.c | 22 +++++--- libmpdemux/demuxer.c | 4 +- libmpdemux/tv.c | 32 +++++------ libmpdemux/tvi_bsdbt848.c | 3 +- libmpdemux/tvi_v4l.c | 4 +- libmpdemux/tvi_v4l2.c | 4 +- mencoder.c | 14 ++--- mplayer.c | 12 +++-- 65 files changed, 483 insertions(+), 585 deletions(-) delete mode 100644 libaf/af_mp.c delete mode 100644 libao2/afmt.c delete mode 100644 libao2/afmt.h diff --git a/Makefile b/Makefile index a246f90339..d3f52f13ca 100644 --- a/Makefile +++ b/Makefile @@ -20,7 +20,7 @@ DO_MAKE = @ for i in $(SUBDIRS); do $(MAKE) -C $$i $@; done endif SRCS_COMMON = cpudetect.c codec-cfg.c spudec.c playtree.c playtreeparser.c asxparser.c vobsub.c subreader.c sub_cc.c find_sub.c m_config.c m_option.c parser-cfg.c m_struct.c edl.c -SRCS_MENCODER = mencoder.c mp_msg-mencoder.c $(SRCS_COMMON) libao2/afmt.c divx4_vbr.c libvo/aclib.c libvo/osd.c libvo/sub.c libvo/font_load.c libvo/font_load_ft.c xvid_vbr.c parser-mecmd.c +SRCS_MENCODER = mencoder.c mp_msg-mencoder.c $(SRCS_COMMON) divx4_vbr.c libvo/aclib.c libvo/osd.c libvo/sub.c libvo/font_load.c libvo/font_load_ft.c xvid_vbr.c parser-mecmd.c SRCS_MPLAYER = mplayer.c mp_msg.c $(SRCS_COMMON) mixer.c parser-mpcmd.c ifeq ($(UNRARLIB),yes) diff --git a/libaf/Makefile b/libaf/Makefile index 317547bf56..47780231a6 100644 --- a/libaf/Makefile +++ b/libaf/Makefile @@ -2,7 +2,7 @@ include config.mak LIBNAME = libaf.a -SRCS=af.c af_mp.c af_dummy.c af_delay.c af_channels.c af_format.c af_resample.c \ +SRCS=af.c af_dummy.c af_delay.c af_channels.c af_format.c af_resample.c \ window.c filter.c af_volume.c af_equalizer.c af_tools.c af_comp.c af_gate.c \ af_pan.c af_surround.c af_sub.c af_export.c af_volnorm.c af_extrastereo.c \ af_lavcresample.c af_sweep.c af_hrtf.c $(OPTIONAL_SRCS) diff --git a/libaf/af_comp.c b/libaf/af_comp.c index be03957bff..0ae83fe93b 100644 --- a/libaf/af_comp.c +++ b/libaf/af_comp.c @@ -44,7 +44,7 @@ static int control(struct af_instance_s* af, int cmd, void* arg) af->data->rate = ((af_data_t*)arg)->rate; af->data->nch = ((af_data_t*)arg)->nch; - af->data->format = AF_FORMAT_F | AF_FORMAT_NE; + af->data->format = AF_FORMAT_FLOAT_NE; af->data->bps = 4; // Time constant set to 0.1s diff --git a/libaf/af_equalizer.c b/libaf/af_equalizer.c index 7613ba087a..0f9533d6d0 100644 --- a/libaf/af_equalizer.c +++ b/libaf/af_equalizer.c @@ -87,7 +87,7 @@ static int control(struct af_instance_s* af, int cmd, void* arg) af->data->rate = ((af_data_t*)arg)->rate; af->data->nch = ((af_data_t*)arg)->nch; - af->data->format = AF_FORMAT_NE | AF_FORMAT_F; + af->data->format = AF_FORMAT_FLOAT_NE; af->data->bps = 4; // Calculate number of active filters @@ -173,7 +173,7 @@ static af_data_t* play(struct af_instance_s* af, af_data_t* data) float* end = in + c->len/4; // Block loop end while(in < end){ - register uint32_t k = 0; // Frequency band index + register int k = 0; // Frequency band index register float yt = *in; // Current input sample in+=nch; diff --git a/libaf/af_export.c b/libaf/af_export.c index f64299ba21..c685cb10b4 100644 --- a/libaf/af_export.c +++ b/libaf/af_export.c @@ -72,7 +72,7 @@ static int control(struct af_instance_s* af, int cmd, void* arg) // Accept only int16_t as input format (which sucks) af->data->rate = ((af_data_t*)arg)->rate; af->data->nch = ((af_data_t*)arg)->nch; - af->data->format = AF_FORMAT_SI | AF_FORMAT_NE; + af->data->format = AF_FORMAT_S16_NE; af->data->bps = 2; // If buffer length isn't set, set it to the default value @@ -163,7 +163,6 @@ static int control(struct af_instance_s* af, int cmd, void* arg) */ static void uninit( struct af_instance_s* af ) { - int i; if (af->data){ free(af->data); af->data = NULL; diff --git a/libaf/af_extrastereo.c b/libaf/af_extrastereo.c index 36674e9ffa..f04ef080f7 100644 --- a/libaf/af_extrastereo.c +++ b/libaf/af_extrastereo.c @@ -37,7 +37,7 @@ static int control(struct af_instance_s* af, int cmd, void* arg) af->data->rate = ((af_data_t*)arg)->rate; af->data->nch = 2; - af->data->format = AF_FORMAT_SI | AF_FORMAT_NE; + af->data->format = AF_FORMAT_S16_NE; af->data->bps = 2; return af_test_output(af,(af_data_t*)arg); diff --git a/libaf/af_format.c b/libaf/af_format.c index 8ad80046f9..68c0a647f3 100644 --- a/libaf/af_format.c +++ b/libaf/af_format.c @@ -43,7 +43,7 @@ static void float2int(void* in, void* out, int len, int bps); static void int2float(void* in, void* out, int len, int bps); // Convert from string to format -static int str2fmt(char* str) +int af_str2fmt(char* str) { int format=0; // Scan for endianess @@ -87,16 +87,34 @@ static int str2fmt(char* str) return format; } +inline int af_fmt2bits(int format) +{ + return (format & AF_FORMAT_BITS_MASK)+8; +// return (((format & AF_FORMAT_BITS_MASK)>>3)+1) * 8; +#if 0 + switch(format & AF_FORMAT_BITS_MASK) + { + case AF_FORMAT_8BIT: return 8; + case AF_FORMAT_16BIT: return 16; + case AF_FORMAT_24BIT: return 24; + case AF_FORMAT_32BIT: return 32; + case AF_FORMAT_48BIT: return 48; + } +#endif + return -1; +} + /* Convert format to str input str is a buffer for the converted string, size is the size of the buffer */ -char* fmt2str(int format, char* str, size_t size) +char* af_fmt2str(int format, char* str, int size) { int i=0; - // Print endinaness + + // Endianess if(AF_FORMAT_LE == (format & AF_FORMAT_END_MASK)) - i+=snprintf(str,size,"little endian "); + i+=snprintf(str,size-i,"little endian "); else - i+=snprintf(str,size,"big endian "); + i+=snprintf(str,size-i,"big endian "); if(format & AF_FORMAT_SPECIAL_MASK){ switch(format & AF_FORMAT_SPECIAL_MASK){ @@ -108,12 +126,17 @@ char* fmt2str(int format, char* str, size_t size) i+=snprintf(&str[i],size-i,"MPEG 2 "); break; case(AF_FORMAT_AC3): i+=snprintf(&str[i],size-i,"AC3 "); break; + default: + printf("Unknown special\n"); } } else{ + // Bits + i+=snprintf(&str[i],size-i,"%d-bit ", af_fmt2bits(format)); + // Point if(AF_FORMAT_F == (format & AF_FORMAT_POINT_MASK)) - i+=snprintf(&str[i],size,"float "); + i+=snprintf(&str[i],size-i,"float "); else{ // Sign if(AF_FORMAT_US == (format & AF_FORMAT_SIGN_MASK)) @@ -121,7 +144,7 @@ char* fmt2str(int format, char* str, size_t size) else i+=snprintf(&str[i],size-i,"signed "); - i+=snprintf(&str[i],size,"int "); + i+=snprintf(&str[i],size-i,"int "); } } return str; @@ -148,7 +171,7 @@ static int check_format(int format) case(AF_FORMAT_MPEG2): case(AF_FORMAT_AC3): af_msg(AF_MSG_ERROR,"[format] Sample format %s not yet supported \n", - fmt2str(format,buf,255)); + af_fmt2str(format,buf,255)); return AF_ERROR; } return AF_OK; @@ -173,9 +196,9 @@ static int control(struct af_instance_s* af, int cmd, void* arg) (AF_OK != check_format(af->data->format))) return AF_ERROR; - af_msg(AF_MSG_VERBOSE,"[format] Changing sample format from %ibit %sto %ibit %s \n", - ((af_data_t*)arg)->bps*8,fmt2str(((af_data_t*)arg)->format,buf1,255), - af->data->bps*8,fmt2str(af->data->format,buf2,255)); + af_msg(AF_MSG_VERBOSE,"[format] Changing sample format from %sto %s \n", + af_fmt2str(((af_data_t*)arg)->format,buf1,255), + af_fmt2str(af->data->format,buf2,255)); af->data->rate = ((af_data_t*)arg)->rate; af->data->nch = ((af_data_t*)arg)->nch; @@ -190,7 +213,7 @@ static int control(struct af_instance_s* af, int cmd, void* arg) str[0] = '\0'; sscanf((char*)arg,"%i:%s",&bps,str); // Convert string to format - format = str2fmt(str); + format = af_str2fmt(str); // Automatic correction of errors switch(format & AF_FORMAT_SPECIAL_MASK){ diff --git a/libaf/af_format.h b/libaf/af_format.h index f7b2a15b16..82eac84817 100644 --- a/libaf/af_format.h +++ b/libaf/af_format.h @@ -1,6 +1,8 @@ /* The sample format system used lin libaf is based on bitmasks. The format definition only refers to the storage format not the resolution. */ +#ifndef __af_format_h__ +#define __af_format_h__ // Endianess #define AF_FORMAT_BE (0<<0) // Big Endian @@ -14,8 +16,8 @@ #endif // Signed/unsigned -#define AF_FORMAT_SI (0<<1) // SIgned -#define AF_FORMAT_US (1<<1) // Un Signed +#define AF_FORMAT_SI (0<<1) // Signed +#define AF_FORMAT_US (1<<1) // Unsigned #define AF_FORMAT_SIGN_MASK (1<<1) // Fixed or floating point @@ -23,13 +25,63 @@ #define AF_FORMAT_F (1<<2) // Foating point #define AF_FORMAT_POINT_MASK (1<<2) +// Bits used +#define AF_FORMAT_8BIT (0<<3) +#define AF_FORMAT_16BIT (1<<3) +#define AF_FORMAT_24BIT (2<<3) +#define AF_FORMAT_32BIT (3<<3) +#define AF_FORMAT_40BIT (4<<3) +#define AF_FORMAT_48BIT (5<<3) +#define AF_FORMAT_BITS_MASK (7<<3) + // Special flags refering to non pcm data -#define AF_FORMAT_MU_LAW (1<<3) // -#define AF_FORMAT_A_LAW (2<<3) // -#define AF_FORMAT_MPEG2 (3<<3) // MPEG(2) audio -#define AF_FORMAT_AC3 (4<<3) // Dolby Digital AC3 -#define AF_FORMAT_IMA_ADPCM AF_FORMAT_LE|AF_FORMAT_SI // Same as 16 bit signed int -#define AF_FORMAT_SPECIAL_MASK (7<<3) +#define AF_FORMAT_MU_LAW (1<<6) +#define AF_FORMAT_A_LAW (2<<6) +#define AF_FORMAT_MPEG2 (3<<6) // MPEG(2) audio +#define AF_FORMAT_AC3 (4<<6) // Dolby Digital AC3 +#define AF_FORMAT_IMA_ADPCM (5<<6) +#define AF_FORMAT_SPECIAL_MASK (7<<6) + +// PREDEFINED formats + +#define AF_FORMAT_U8 (AF_FORMAT_I|AF_FORMAT_US|AF_FORMAT_8BIT|AF_FORMAT_NE) +#define AF_FORMAT_S8 (AF_FORMAT_I|AF_FORMAT_SI|AF_FORMAT_8BIT|AF_FORMAT_NE) +#define AF_FORMAT_U16_LE (AF_FORMAT_I|AF_FORMAT_US|AF_FORMAT_16BIT|AF_FORMAT_LE) +#define AF_FORMAT_U16_BE (AF_FORMAT_I|AF_FORMAT_US|AF_FORMAT_16BIT|AF_FORMAT_BE) +#define AF_FORMAT_S16_LE (AF_FORMAT_I|AF_FORMAT_SI|AF_FORMAT_16BIT|AF_FORMAT_LE) +#define AF_FORMAT_S16_BE (AF_FORMAT_I|AF_FORMAT_SI|AF_FORMAT_16BIT|AF_FORMAT_BE) +#define AF_FORMAT_U24_LE (AF_FORMAT_I|AF_FORMAT_US|AF_FORMAT_24BIT|AF_FORMAT_LE) +#define AF_FORMAT_U24_BE (AF_FORMAT_I|AF_FORMAT_US|AF_FORMAT_24BIT|AF_FORMAT_BE) +#define AF_FORMAT_S24_LE (AF_FORMAT_I|AF_FORMAT_SI|AF_FORMAT_24BIT|AF_FORMAT_LE) +#define AF_FORMAT_S24_BE (AF_FORMAT_I|AF_FORMAT_SI|AF_FORMAT_24BIT|AF_FORMAT_BE) +#define AF_FORMAT_U32_LE (AF_FORMAT_I|AF_FORMAT_US|AF_FORMAT_32BIT|AF_FORMAT_LE) +#define AF_FORMAT_U32_BE (AF_FORMAT_I|AF_FORMAT_US|AF_FORMAT_32BIT|AF_FORMAT_BE) +#define AF_FORMAT_S32_LE (AF_FORMAT_I|AF_FORMAT_SI|AF_FORMAT_32BIT|AF_FORMAT_LE) +#define AF_FORMAT_S32_BE (AF_FORMAT_I|AF_FORMAT_SI|AF_FORMAT_32BIT|AF_FORMAT_BE) + +#define AF_FORMAT_FLOAT_LE (AF_FORMAT_F|AF_FORMAT_32BIT|AF_FORMAT_LE) +#define AF_FORMAT_FLOAT_BE (AF_FORMAT_F|AF_FORMAT_32BIT|AF_FORMAT_BE) + +#ifdef WORDS_BIGENDIAN +#define AF_FORMAT_U16_NE AF_FORMAT_U16_BE +#define AF_FORMAT_S16_NE AF_FORMAT_S16_BE +#define AF_FORMAT_U24_NE AF_FORMAT_U24_BE +#define AF_FORMAT_S24_NE AF_FORMAT_S24_BE +#define AF_FORMAT_U32_NE AF_FORMAT_U32_BE +#define AF_FORMAT_S32_NE AF_FORMAT_S32_BE +#define AF_FORMAT_FLOAT_NE AF_FORMAT_FLOAT_BE +#else +#define AF_FORMAT_U16_NE AF_FORMAT_U16_LE +#define AF_FORMAT_S16_NE AF_FORMAT_S16_LE +#define AF_FORMAT_U24_NE AF_FORMAT_U24_LE +#define AF_FORMAT_S24_NE AF_FORMAT_S24_LE +#define AF_FORMAT_U32_NE AF_FORMAT_U32_LE +#define AF_FORMAT_S32_NE AF_FORMAT_S32_LE +#define AF_FORMAT_FLOAT_NE AF_FORMAT_FLOAT_LE +#endif -extern char* fmt2str(int format, char* str, size_t size); +extern int af_str2fmt(char *str); +extern int af_fmt2bits(int format); +extern char* af_fmt2str(int format, char* str, int size); +#endif /* __af_format_h__ */ diff --git a/libaf/af_gate.c b/libaf/af_gate.c index 55acc2970a..f0e7a3df9f 100644 --- a/libaf/af_gate.c +++ b/libaf/af_gate.c @@ -42,7 +42,7 @@ static int control(struct af_instance_s* af, int cmd, void* arg) af->data->rate = ((af_data_t*)arg)->rate; af->data->nch = ((af_data_t*)arg)->nch; - af->data->format = AF_FORMAT_F | AF_FORMAT_NE; + af->data->format = AF_FORMAT_FLOAT_NE; af->data->bps = 4; // Time constant set to 0.1s diff --git a/libaf/af_hrtf.c b/libaf/af_hrtf.c index 8f302e8448..d516494943 100644 --- a/libaf/af_hrtf.c +++ b/libaf/af_hrtf.c @@ -119,7 +119,7 @@ static int control(struct af_instance_s *af, int cmd, void* arg) if(af->data->nch < 5) { af->data->nch = 5; } - af->data->format = AF_FORMAT_SI | AF_FORMAT_NE; + af->data->format = AF_FORMAT_S16_NE; af->data->bps = 2; return af_test_output(af, (af_data_t*)arg); case AF_CONTROL_COMMAND_LINE: diff --git a/libaf/af_lavcresample.c b/libaf/af_lavcresample.c index c37807865b..20d9ffc878 100644 --- a/libaf/af_lavcresample.c +++ b/libaf/af_lavcresample.c @@ -52,7 +52,7 @@ static int control(struct af_instance_s* af, int cmd, void* arg) af->data->nch = data->nch; if (af->data->nch > CHANS) af->data->nch = CHANS; - af->data->format = AF_FORMAT_SI | AF_FORMAT_NE; + af->data->format = AF_FORMAT_S16_NE; af->data->bps = 2; g= ff_gcd(af->data->rate, data->rate); af->mul.n = af->data->rate/g; diff --git a/libaf/af_mp.c b/libaf/af_mp.c deleted file mode 100644 index 50bbc90e2e..0000000000 --- a/libaf/af_mp.c +++ /dev/null @@ -1,98 +0,0 @@ -#include "af.h" - -/* Decodes the format from mplayer format to libaf format */ -int af_format_decode(int ifmt) -{ - int ofmt = ~0; - // Check input ifmt - switch(ifmt){ - case(AFMT_U8): - ofmt = AF_FORMAT_LE|AF_FORMAT_US; break; - case(AFMT_S8): - ofmt = AF_FORMAT_LE|AF_FORMAT_SI; break; - case(AFMT_S16_LE): - ofmt = AF_FORMAT_LE|AF_FORMAT_SI; break; - case(AFMT_S16_BE): - ofmt = AF_FORMAT_BE|AF_FORMAT_SI; break; - case(AFMT_U16_LE): - ofmt = AF_FORMAT_LE|AF_FORMAT_US; break; - case(AFMT_U16_BE): - ofmt = AF_FORMAT_BE|AF_FORMAT_US; break; - case(AFMT_S24_LE): - ofmt = AF_FORMAT_LE|AF_FORMAT_SI; break; - case(AFMT_S24_BE): - ofmt = AF_FORMAT_BE|AF_FORMAT_SI; break; - case(AFMT_U24_LE): - ofmt = AF_FORMAT_LE|AF_FORMAT_US; break; - case(AFMT_U24_BE): - ofmt = AF_FORMAT_BE|AF_FORMAT_US; break; - case(AFMT_S32_LE): - ofmt = AF_FORMAT_LE|AF_FORMAT_SI; break; - case(AFMT_S32_BE): - ofmt = AF_FORMAT_BE|AF_FORMAT_SI; break; - case(AFMT_U32_LE): - ofmt = AF_FORMAT_LE|AF_FORMAT_US; break; - case(AFMT_U32_BE): - ofmt = AF_FORMAT_BE|AF_FORMAT_US; break; - case(AFMT_IMA_ADPCM): - ofmt = AF_FORMAT_IMA_ADPCM; break; - case(AFMT_MU_LAW): - ofmt = AF_FORMAT_MU_LAW; break; - case(AFMT_A_LAW): - ofmt = AF_FORMAT_A_LAW; break; - case(AFMT_MPEG): - ofmt = AF_FORMAT_MPEG2; break; - case(AFMT_AC3): - ofmt = AF_FORMAT_AC3; break; - case(AFMT_FLOAT): - ofmt = AF_FORMAT_F | AF_FORMAT_NE; break; - default: - if ((ifmt & AFMT_AF_FLAGS) == AFMT_AF_FLAGS) { - ofmt = ifmt & ~AFMT_AF_FLAGS; - break; - } - //This can not happen .... - af_msg(AF_MSG_FATAL,"Unrecognized input audio format %i\n",ifmt); - break; - } - return ofmt; -} - -/* Encodes the format from libaf format to mplayer (OSS) format */ -int af_format_encode(void* fmtp) -{ - af_data_t* fmt=(af_data_t*) fmtp; - switch(fmt->format&AF_FORMAT_SPECIAL_MASK){ - case 0: // PCM: - if((fmt->format&AF_FORMAT_POINT_MASK)==AF_FORMAT_I){ - if((fmt->format&AF_FORMAT_SIGN_MASK)==AF_FORMAT_SI){ - // signed int PCM: - switch(fmt->bps){ - case 1: return AFMT_S8; - case 2: return (fmt->format&AF_FORMAT_LE) ? AFMT_S16_LE : AFMT_S16_BE; - case 3: return (fmt->format&AF_FORMAT_LE) ? AFMT_S24_LE : AFMT_S24_BE; - case 4: return (fmt->format&AF_FORMAT_LE) ? AFMT_S32_LE : AFMT_S32_BE; - } - } else { - // unsigned int PCM: - switch(fmt->bps){ - case 1: return AFMT_U8; - case 2: return (fmt->format&AF_FORMAT_LE) ? AFMT_U16_LE : AFMT_U16_BE; - case 3: return (fmt->format&AF_FORMAT_LE) ? AFMT_U24_LE : AFMT_U24_BE; - case 4: return (fmt->format&AF_FORMAT_LE) ? AFMT_U32_LE : AFMT_U32_BE; - } - } - } else { - // float PCM: - return AFMT_FLOAT; // FIXME? - } - break; - case AF_FORMAT_MU_LAW: return AFMT_MU_LAW; - case AF_FORMAT_A_LAW: return AFMT_A_LAW; - case AF_FORMAT_MPEG2: return AFMT_MPEG; - case AF_FORMAT_AC3: return AFMT_AC3; - case AF_FORMAT_IMA_ADPCM: return AFMT_IMA_ADPCM; - } - return (fmt->format | AFMT_AF_FLAGS); -} - diff --git a/libaf/af_mp.h b/libaf/af_mp.h index 7d3918a55a..cd6ec92806 100644 --- a/libaf/af_mp.h +++ b/libaf/af_mp.h @@ -5,7 +5,6 @@ #include "../config.h" #include "../mp_msg.h" #include "../cpudetect.h" -#include "../libao2/afmt.h" /* Set the initialization type from mplayers cpudetect */ #ifdef AF_INIT_TYPE @@ -20,8 +19,4 @@ #define af_msg(lev, args... ) \ mp_msg(MSGT_AFILTER,(((lev)<0)?((lev)+3):(((lev)==0)?MSGL_INFO:((lev)+5))), ##args ) -/* Decodes the format from mplayer format to libaf format */ -extern int af_format_decode(int format); -extern int af_format_encode(void* fmt); - #endif /* __af_mp_h__ */ diff --git a/libaf/af_pan.c b/libaf/af_pan.c index 78ffd36a28..268ffd6e4b 100644 --- a/libaf/af_pan.c +++ b/libaf/af_pan.c @@ -37,7 +37,7 @@ static int control(struct af_instance_s* af, int cmd, void* arg) if(!arg) return AF_ERROR; af->data->rate = ((af_data_t*)arg)->rate; - af->data->format = AF_FORMAT_F | AF_FORMAT_NE; + af->data->format = AF_FORMAT_FLOAT_NE; af->data->bps = 4; af->mul.n = af->data->nch; af->mul.d = ((af_data_t*)arg)->nch; diff --git a/libaf/af_resample.c b/libaf/af_resample.c index 0cd5402620..00d06fa8ec 100644 --- a/libaf/af_resample.c +++ b/libaf/af_resample.c @@ -135,29 +135,28 @@ static int set_types(struct af_instance_s* af, af_data_t* data) // Make sure this filter isn't redundant if((af->data->rate == data->rate) || (af->data->rate == 0)) return AF_DETACH; - /* If sloppy and small resampling difference (2%) */ rd = abs((float)af->data->rate - (float)data->rate)/(float)data->rate; if((((s->setup & FREQ_MASK) == FREQ_SLOPPY) && (rd < 0.02) && - (data->format != (AF_FORMAT_NE | AF_FORMAT_F))) || + (data->format != (AF_FORMAT_FLOAT_NE))) || ((s->setup & RSMP_MASK) == RSMP_LIN)){ s->setup = (s->setup & ~RSMP_MASK) | RSMP_LIN; - af->data->format = AF_FORMAT_NE | AF_FORMAT_SI; + af->data->format = AF_FORMAT_S16_NE; af->data->bps = 2; af_msg(AF_MSG_VERBOSE,"[resample] Using linear interpolation. \n"); } else{ /* If the input format is float or if float is explicitly selected use float, otherwise use int */ - if((data->format == (AF_FORMAT_NE | AF_FORMAT_F)) || + if((data->format == (AF_FORMAT_FLOAT_NE)) || ((s->setup & RSMP_MASK) == RSMP_FLOAT)){ s->setup = (s->setup & ~RSMP_MASK) | RSMP_FLOAT; - af->data->format = AF_FORMAT_NE | AF_FORMAT_F; + af->data->format = AF_FORMAT_FLOAT_NE; af->data->bps = 4; } else{ s->setup = (s->setup & ~RSMP_MASK) | RSMP_INT; - af->data->format = AF_FORMAT_NE | AF_FORMAT_SI; + af->data->format = AF_FORMAT_S16_NE; af->data->bps = 2; } af_msg(AF_MSG_VERBOSE,"[resample] Using %s processing and %s frequecy" diff --git a/libaf/af_sub.c b/libaf/af_sub.c index 4845018d1a..e57c99dca1 100644 --- a/libaf/af_sub.c +++ b/libaf/af_sub.c @@ -61,7 +61,7 @@ static int control(struct af_instance_s* af, int cmd, void* arg) af->data->rate = ((af_data_t*)arg)->rate; af->data->nch = max(s->ch+1,((af_data_t*)arg)->nch); - af->data->format = AF_FORMAT_F | AF_FORMAT_NE; + af->data->format = AF_FORMAT_FLOAT_NE; af->data->bps = 4; // Design low-pass filter diff --git a/libaf/af_surround.c b/libaf/af_surround.c index 590eaf74eb..e00c23f727 100644 --- a/libaf/af_surround.c +++ b/libaf/af_surround.c @@ -93,7 +93,7 @@ static int control(struct af_instance_s* af, int cmd, void* arg) float fc; af->data->rate = ((af_data_t*)arg)->rate; af->data->nch = ((af_data_t*)arg)->nch*2; - af->data->format = AF_FORMAT_F | AF_FORMAT_NE; + af->data->format = AF_FORMAT_FLOAT_NE; af->data->bps = 4; if (af->data->nch != 4){ diff --git a/libaf/af_sweep.c b/libaf/af_sweep.c index 8ed84266e1..619ebf7868 100644 --- a/libaf/af_sweep.c +++ b/libaf/af_sweep.c @@ -25,7 +25,7 @@ static int control(struct af_instance_s* af, int cmd, void* arg) switch(cmd){ case AF_CONTROL_REINIT: af->data->nch = data->nch; - af->data->format = AF_FORMAT_SI | AF_FORMAT_NE; + af->data->format = AF_FORMAT_S16_NE; af->data->bps = 2; af->data->rate = data->rate; diff --git a/libaf/af_volnorm.c b/libaf/af_volnorm.c index c1fed6a9d3..60485118b0 100644 --- a/libaf/af_volnorm.c +++ b/libaf/af_volnorm.c @@ -79,11 +79,11 @@ static int control(struct af_instance_s* af, int cmd, void* arg) af->data->rate = ((af_data_t*)arg)->rate; af->data->nch = ((af_data_t*)arg)->nch; - if(((af_data_t*)arg)->format == (AF_FORMAT_SI | AF_FORMAT_NE)){ - af->data->format = AF_FORMAT_SI | AF_FORMAT_NE; + if(((af_data_t*)arg)->format == (AF_FORMAT_S16_NE)){ + af->data->format = AF_FORMAT_S16_NE; af->data->bps = 2; }else{ - af->data->format = AF_FORMAT_F | AF_FORMAT_NE; + af->data->format = AF_FORMAT_FLOAT_NE; af->data->bps = 4; } return af_test_output(af,(af_data_t*)arg); @@ -288,14 +288,14 @@ static af_data_t* play(struct af_instance_s* af, af_data_t* data) { af_volnorm_t *s = af->setup; - if(af->data->format == (AF_FORMAT_SI | AF_FORMAT_NE)) + if(af->data->format == (AF_FORMAT_S16_NE)) { if (s->method) method2_int16(s, data); else method1_int16(s, data); } - else if(af->data->format == (AF_FORMAT_F | AF_FORMAT_NE)) + else if(af->data->format == (AF_FORMAT_FLOAT_NE)) { if (s->method) method2_float(s, data); diff --git a/libaf/af_volume.c b/libaf/af_volume.c index 6c3d73be65..e6221fe51a 100644 --- a/libaf/af_volume.c +++ b/libaf/af_volume.c @@ -60,8 +60,8 @@ static int control(struct af_instance_s* af, int cmd, void* arg) af->data->rate = ((af_data_t*)arg)->rate; af->data->nch = ((af_data_t*)arg)->nch; - if(s->fast && (((af_data_t*)arg)->format != (AF_FORMAT_F | AF_FORMAT_NE))){ - af->data->format = AF_FORMAT_SI | AF_FORMAT_NE; + if(s->fast && (((af_data_t*)arg)->format != (AF_FORMAT_FLOAT_NE))){ + af->data->format = AF_FORMAT_S16_NE; af->data->bps = 2; } else{ @@ -70,7 +70,7 @@ static int control(struct af_instance_s* af, int cmd, void* arg) float t = 2.0-cos(x); s->time = 1.0 - (t - sqrt(t*t - 1)); af_msg(AF_MSG_DEBUG0,"[volume] Forgetting factor = %0.5f\n",s->time); - af->data->format = AF_FORMAT_F | AF_FORMAT_NE; + af->data->format = AF_FORMAT_FLOAT_NE; af->data->bps = 4; } return af_test_output(af,(af_data_t*)arg); @@ -140,7 +140,7 @@ static af_data_t* play(struct af_instance_s* af, af_data_t* data) register int i = 0; // Basic operation volume control only (used on slow machines) - if(af->data->format == (AF_FORMAT_SI | AF_FORMAT_NE)){ + if(af->data->format == (AF_FORMAT_S16_NE)){ int16_t* a = (int16_t*)c->audio; // Audio data int len = c->len/2; // Number of samples for(ch = 0; ch < nch ; ch++){ @@ -154,7 +154,7 @@ static af_data_t* play(struct af_instance_s* af, af_data_t* data) } } // Machine is fast and data is floating point - else if(af->data->format == (AF_FORMAT_F | AF_FORMAT_NE)){ + else if(af->data->format == (AF_FORMAT_FLOAT_NE)){ float* a = (float*)c->audio; // Audio data int len = c->len/4; // Number of samples for(ch = 0; ch < nch ; ch++){ diff --git a/libaf/config.h b/libaf/config.h index 676979ef6b..22a20ae4fa 100644 --- a/libaf/config.h +++ b/libaf/config.h @@ -8,6 +8,8 @@ //============================================================================= */ +#include "../config.h" // WORDS_BIGENDIAN + // Number of channels #ifndef AF_NCH #define AF_NCH 6 diff --git a/libao2/Makefile b/libao2/Makefile index bc3002b1fb..cb1bd674d0 100644 --- a/libao2/Makefile +++ b/libao2/Makefile @@ -2,7 +2,7 @@ include config.mak LIBNAME = libao2.a -SRCS=afmt.c audio_out.c ao_mpegpes.c ao_null.c ao_pcm.c ao_plugin.c pl_delay.c pl_format.c pl_surround.c remez.c pl_resample.c pl_volume.c pl_extrastereo.c pl_volnorm.c pl_eq.c $(OPTIONAL_SRCS) +SRCS=audio_out.c ao_mpegpes.c ao_null.c ao_pcm.c ao_plugin.c pl_delay.c pl_format.c pl_surround.c remez.c pl_resample.c pl_volume.c pl_extrastereo.c pl_volnorm.c pl_eq.c $(OPTIONAL_SRCS) OBJS=$(SRCS:.c=.o) diff --git a/libao2/afmt.c b/libao2/afmt.c deleted file mode 100644 index 95cd817ca2..0000000000 --- a/libao2/afmt.c +++ /dev/null @@ -1,90 +0,0 @@ -#include -#include - -#include "config.h" -#include "afmt.h" - -char *audio_out_format_name(int format) -{ - switch (format) - { - case AFMT_MU_LAW: - return("Mu-Law"); - case AFMT_A_LAW: - return("A-Law"); - case AFMT_IMA_ADPCM: - return("Ima-ADPCM"); - case AFMT_S8: - return("Signed 8-bit"); - case AFMT_U8: - return("Unsigned 8-bit"); - case AFMT_U16_LE: - return("Unsigned 16-bit (Little-Endian)"); - case AFMT_U16_BE: - return("Unsigned 16-bit (Big-Endian)"); - case AFMT_S16_LE: - return("Signed 16-bit (Little-Endian)"); - case AFMT_S16_BE: - return("Signed 16-bit (Big-Endian)"); - case AFMT_MPEG: - return("MPEG (2) audio"); - case AFMT_AC3: - return("AC3"); - case AFMT_U32_LE: - return("Unsigned 32-bit (Little-Endian)"); - case AFMT_U32_BE: - return("Unsigned 32-bit (Big-Endian)"); - case AFMT_S32_LE: - return("Signed 32-bit (Little-Endian)"); - case AFMT_S32_BE: - return("Signed 32-bit (Big-Endian)"); - case AFMT_U24_LE: - return("Unsigned 24-bit (Little-Endian)"); - case AFMT_U24_BE: - return("Unsigned 24-bit (Big-Endian)"); - case AFMT_S24_LE: - return("Signed 24-bit (Little-Endian)"); - case AFMT_S24_BE: - return("Signed 24-bit (Big-Endian)"); - case AFMT_FLOAT: - return("Floating Point"); - } - return("Unknown"); -} - -// return number of bits for 1 sample in one channel, or 8 bits for compressed -int audio_out_format_bits(int format){ - switch (format) - { - case AFMT_S16_LE: - case AFMT_S16_BE: - case AFMT_U16_LE: - case AFMT_U16_BE: - return 16;//16 bits - - case AFMT_S32_LE: - case AFMT_S32_BE: - case AFMT_U32_LE: - case AFMT_U32_BE: - case AFMT_FLOAT: - return 32; - - case AFMT_S24_LE: - case AFMT_S24_BE: - case AFMT_U24_LE: - case AFMT_U24_BE: - return 24; - - case AFMT_MU_LAW: - case AFMT_A_LAW: - case AFMT_IMA_ADPCM: - case AFMT_S8: - case AFMT_U8: - case AFMT_MPEG: - case AFMT_AC3: - default: - return 8;//default 1 byte - - } - return 8; -} diff --git a/libao2/afmt.h b/libao2/afmt.h deleted file mode 100644 index 04dc762c1b..0000000000 --- a/libao2/afmt.h +++ /dev/null @@ -1,84 +0,0 @@ - -/* Defines that AFMT_ stuff */ - -#ifdef HAVE_SYS_SOUNDCARD_H -#include /* For AFMT_* on linux */ -#else -#ifdef HAVE_SOUNDCARD_H -#include /* OpenBSD have this instead of */ -#endif -#endif - -#include "config.h" /* for native endianness */ - -/* standard, old OSS audio formats */ -#ifndef AFMT_MU_LAW -# define AFMT_MU_LAW 0x00000001 -# define AFMT_A_LAW 0x00000002 -# define AFMT_IMA_ADPCM 0x00000004 -# define AFMT_U8 0x00000008 -# define AFMT_S16_LE 0x00000010 /* Little endian signed 16*/ -# define AFMT_S16_BE 0x00000020 /* Big endian signed 16 */ -# define AFMT_S8 0x00000040 -# define AFMT_U16_LE 0x00000080 /* Little endian U16 */ -# define AFMT_U16_BE 0x00000100 /* Big endian U16 */ -#endif - -#ifndef AFMT_MPEG -# define AFMT_MPEG 0x00000200 /* MPEG (2) audio */ -#endif - -#ifndef AFMT_AC3 -# define AFMT_AC3 0x00000400 /* Dolby Digital AC3 */ -#endif - -/* 24 bit formats from the linux kernel */ -#ifndef AFMT_S24_LE - -// FreeBSD fix... -#if AFMT_S32_LE == 0x1000 - -#define AFMT_S24_LE 0x00010000 -#define AFMT_S24_BE 0x00020000 -#define AFMT_U24_LE 0x00040000 -#define AFMT_U24_BE 0x00080000 - -#else - -#define AFMT_S24_LE 0x00000800 -#define AFMT_S24_BE 0x00001000 -#define AFMT_U24_LE 0x00002000 -#define AFMT_U24_BE 0x00004000 - -#endif - -#endif - -/* 32 bit formats from the linux kernel */ -#ifndef AFMT_S32_LE -#define AFMT_S32_LE 0x00008000 -#define AFMT_S32_BE 0x00010000 -#define AFMT_U32_LE 0x00020000 -#define AFMT_U32_BE 0x00040000 -#endif - -/* native endian formats */ -#ifndef AFMT_S16_NE -# if WORDS_BIGENDIAN -# define AFMT_S16_NE AFMT_S16_BE -# define AFMT_S24_NE AFMT_S24_BE -# define AFMT_S32_NE AFMT_S32_BE -# else -# define AFMT_S16_NE AFMT_S16_LE -# define AFMT_S24_NE AFMT_S24_LE -# define AFMT_S32_NE AFMT_S32_LE -# endif -#endif - -#ifndef AFMT_FLOAT -# define AFMT_FLOAT 0x00100000 -#endif - -/* for formats that don't have a corresponding AFMT_* type, - * use the flags from libaf/af_format.h or'ed with this */ -#define AFMT_AF_FLAGS 0x70000000 diff --git a/libao2/ao_alsa.c b/libao2/ao_alsa.c index 2aa6cdaebe..539fd0fa7c 100644 --- a/libao2/ao_alsa.c +++ b/libao2/ao_alsa.c @@ -37,7 +37,7 @@ #include "audio_out.h" #include "audio_out_internal.h" -#include "afmt.h" +#include "libaf/af_format.h" static ao_info_t info = { @@ -125,7 +125,7 @@ static int control(int cmd, void *arg) } if(mixer_device) card = mixer_device; - if(ao_data.format == AFMT_AC3) + if(ao_data.format == AF_FORMAT_AC3) return CONTROL_TRUE; //allocate simple id @@ -275,42 +275,42 @@ static int init(int rate_hz, int channels, int format, int flags) switch (format) { - case AFMT_S8: + case AF_FORMAT_S8: alsa_format = SND_PCM_FORMAT_S8; break; - case AFMT_U8: + case AF_FORMAT_U8: alsa_format = SND_PCM_FORMAT_U8; break; - case AFMT_U16_LE: + case AF_FORMAT_U16_LE: alsa_format = SND_PCM_FORMAT_U16_LE; break; - case AFMT_U16_BE: + case AF_FORMAT_U16_BE: alsa_format = SND_PCM_FORMAT_U16_BE; break; #ifndef WORDS_BIGENDIAN - case AFMT_AC3: + case AF_FORMAT_AC3: #endif - case AFMT_S16_LE: + case AF_FORMAT_S16_LE: alsa_format = SND_PCM_FORMAT_S16_LE; break; #ifdef WORDS_BIGENDIAN - case AFMT_AC3: + case AF_FORMAT_AC3: #endif - case AFMT_S16_BE: + case AF_FORMAT_S16_BE: alsa_format = SND_PCM_FORMAT_S16_BE; break; - case AFMT_S32_LE: + case AF_FORMAT_S32_LE: alsa_format = SND_PCM_FORMAT_S32_LE; break; - case AFMT_S32_BE: + case AF_FORMAT_S32_BE: alsa_format = SND_PCM_FORMAT_S32_BE; break; - case AFMT_FLOAT: + case AF_FORMAT_FLOAT_LE: alsa_format = SND_PCM_FORMAT_FLOAT_LE; break; default: - alsa_format = SND_PCM_FORMAT_MPEG; //? default should be -1 + alsa_format = SND_PCM_FORMAT_MPEG2; //? default should be -1 break; } @@ -412,7 +412,7 @@ static int init(int rate_hz, int channels, int format, int flags) * while opening the abstract alias for the spdif subdevice * 'iec958' */ - if (format == AFMT_AC3) { + if (format == AF_FORMAT_AC3) { unsigned char s[4]; switch (channels) { @@ -590,7 +590,7 @@ static int init(int rate_hz, int channels, int format, int flags) "alsa-init: format %s are not supported by hardware, trying default\n", audio_out_format_name(format)); alsa_format = SND_PCM_FORMAT_S16_LE; - ao_data.format = AFMT_S16_LE; + ao_data.format = AF_FORMAT_S16_LE; ao_data.bps = channels * rate_hz * 2; } diff --git a/libao2/ao_alsa5.c b/libao2/ao_alsa5.c index 68f2cbcaa5..ed073f55ae 100644 --- a/libao2/ao_alsa5.c +++ b/libao2/ao_alsa5.c @@ -13,7 +13,7 @@ #include "audio_out.h" #include "audio_out_internal.h" -#include "afmt.h" +#include "libaf/af_format.h" #include "mp_msg.h" #include "help_mp.h" @@ -75,28 +75,28 @@ static int init(int rate_hz, int channels, int format, int flags) memset(&alsa_format, 0, sizeof(alsa_format)); switch (format) { - case AFMT_S8: + case AF_FORMAT_S8: alsa_format.format = SND_PCM_SFMT_S8; break; - case AFMT_U8: + case AF_FORMAT_U8: alsa_format.format = SND_PCM_SFMT_U8; break; - case AFMT_U16_LE: + case AF_FORMAT_U16_LE: alsa_format.format = SND_PCM_SFMT_U16_LE; break; - case AFMT_U16_BE: + case AF_FORMAT_U16_BE: alsa_format.format = SND_PCM_SFMT_U16_BE; break; #ifndef WORDS_BIGENDIAN - case AFMT_AC3: + case AF_FORMAT_AC3: #endif - case AFMT_S16_LE: + case AF_FORMAT_S16_LE: alsa_format.format = SND_PCM_SFMT_S16_LE; break; #ifdef WORDS_BIGENDIAN - case AFMT_AC3: + case AF_FORMAT_AC3: #endif - case AFMT_S16_BE: + case AF_FORMAT_S16_BE: alsa_format.format = SND_PCM_SFMT_S16_BE; break; default: diff --git a/libao2/ao_arts.c b/libao2/ao_arts.c index 8d2918d74f..ad19b9845b 100644 --- a/libao2/ao_arts.c +++ b/libao2/ao_arts.c @@ -12,12 +12,12 @@ #include "audio_out.h" #include "audio_out_internal.h" -#include "afmt.h" +#include "libaf/af_format.h" #include "config.h" #include "mp_msg.h" #include "help_mp.h" -#define OBTAIN_BITRATE(a) (((a != AFMT_U8) && (a != AFMT_S8)) ? 16 : 8) +#define OBTAIN_BITRATE(a) (((a != AF_FORMAT_U8) && (a != AF_FORMAT_S8)) ? 16 : 8) /* Feel free to experiment with the following values: */ #define ARTS_PACKETS 10 /* Number of audio packets */ @@ -60,12 +60,12 @@ static int init(int rate_hz, int channels, int format, int flags) * using mplayer's audio filters. */ switch (format) { - case AFMT_U8: - case AFMT_S8: - format = AFMT_U8; + case AF_FORMAT_U8: + case AF_FORMAT_S8: + format = AF_FORMAT_U8; break; default: - format = AFMT_S16_LE; /* artsd always expects little endian?*/ + format = AF_FORMAT_S16_LE; /* artsd always expects little endian?*/ break; } @@ -74,7 +74,7 @@ static int init(int rate_hz, int channels, int format, int flags) ao_data.samplerate = rate_hz; ao_data.bps = (rate_hz*channels); - if(format != AFMT_U8 && format != AFMT_S8) + if(format != AF_FORMAT_U8 && format != AF_FORMAT_S8) ao_data.bps*=2; stream=arts_play_stream(rate_hz, OBTAIN_BITRATE(format), channels, "MPlayer"); diff --git a/libao2/ao_dsound.c b/libao2/ao_dsound.c index 0344c7410e..39ab901df8 100644 --- a/libao2/ao_dsound.c +++ b/libao2/ao_dsound.c @@ -28,7 +28,7 @@ #define DIRECTSOUND_VERSION 0x0600 #include -#include "afmt.h" +#include "libaf/af_format.h" #include "audio_out.h" #include "audio_out_internal.h" #include "mp_msg.h" @@ -265,7 +265,7 @@ static int write_buffer(unsigned char *data, int len) if (SUCCEEDED(res)) { - if( (ao_data.channels == 6) && (ao_data.format!=AFMT_AC3) ) { + if( (ao_data.channels == 6) && (ao_data.format!=AF_FORMAT_AC3) ) { // reorder channels while writing to pointers. // it's this easy because buffer size and len are always // aligned to multiples of channels*bytespersample @@ -366,14 +366,14 @@ static int init(int rate, int channels, int format, int flags) //check if the format is supported in general switch(format){ - case AFMT_AC3: - case AFMT_S24_LE: - case AFMT_S16_LE: - case AFMT_S8: + case AF_FORMAT_AC3: + case AF_FORMAT_S24_LE: + case AF_FORMAT_S16_LE: + case AF_FORMAT_S8: break; default: mp_msg(MSGT_AO, MSGL_V,"ao_dsound: format %s not supported defaulting to Signed 16-bit Little-Endian\n",audio_out_format_name(format)); - format=AFMT_S16_LE; + format=AF_FORMAT_S16_LE; } //fill global ao_data ao_data.channels = channels; @@ -389,7 +389,7 @@ static int init(int rate, int channels, int format, int flags) wformat.Format.cbSize = (channels > 2) ? sizeof(WAVEFORMATEXTENSIBLE)-sizeof(WAVEFORMATEX) : 0; wformat.Format.nChannels = channels; wformat.Format.nSamplesPerSec = rate; - if (format == AFMT_AC3) { + if (format == AF_FORMAT_AC3) { wformat.Format.wFormatTag = WAVE_FORMAT_DOLBY_AC3_SPDIF; wformat.Format.wBitsPerSample = 16; wformat.Format.nBlockAlign = 4; diff --git a/libao2/ao_dxr2.c b/libao2/ao_dxr2.c index 7ec4d2c499..f495d12ed4 100644 --- a/libao2/ao_dxr2.c +++ b/libao2/ao_dxr2.c @@ -11,8 +11,7 @@ #include "audio_out.h" #include "audio_out_internal.h" - -#include "afmt.h" +#include "libaf/af_format.h" static ao_info_t info = @@ -158,9 +157,9 @@ static int get_space(){ // return: number of bytes played static int play(void* data,int len,int flags){ // MPEG and AC3 don't work :-( - if(ao_data.format==AFMT_MPEG) + if(ao_data.format==AF_FORMAT_MPEG2) dxr2_send_packet(data,len,0xC0,ao_data.pts); - else if(ao_data.format==AFMT_AC3) + else if(ao_data.format==AF_FORMAT_AC3) dxr2_send_packet(data,len,0x80,ao_data.pts); else { int i; diff --git a/libao2/ao_esd.c b/libao2/ao_esd.c index 11001062d6..a850ad6009 100644 --- a/libao2/ao_esd.c +++ b/libao2/ao_esd.c @@ -32,7 +32,7 @@ #include "audio_out.h" #include "audio_out_internal.h" -#include "afmt.h" +#include "libaf/af_format.h" #include "config.h" #include "mp_msg.h" #include "help_mp.h" @@ -200,14 +200,14 @@ static int init(int rate_hz, int channels, int format, int flags) /* EsounD can play 8bit unsigned and 16bit signed native */ switch (format) { - case AFMT_S8: - case AFMT_U8: + case AF_FORMAT_S8: + case AF_FORMAT_U8: esd_fmt |= ESD_BITS8; - ao_data.format = AFMT_U8; + ao_data.format = AF_FORMAT_U8; break; default: esd_fmt |= ESD_BITS16; - ao_data.format = AFMT_S16_NE; + ao_data.format = AF_FORMAT_S16_NE; bytes_per_sample *= 2; break; } diff --git a/libao2/ao_jack.c b/libao2/ao_jack.c index 0f4ce43061..6e11c9752d 100644 --- a/libao2/ao_jack.c +++ b/libao2/ao_jack.c @@ -14,7 +14,7 @@ #include "audio_out.h" #include "audio_out_internal.h" -#include "afmt.h" +#include "libaf/af_format.h" #include "config.h" #include "mp_msg.h" @@ -146,14 +146,14 @@ static int init(int rate_hz, int channels, int format, int flags) } switch (format) { - case AFMT_U8: - case AFMT_S8: - format = AFMT_U8; + case AF_FORMAT_U8: + case AF_FORMAT_S8: + format = AF_FORMAT_U8; bits_per_sample = 8; m = 1; break; default: - format = AFMT_S16_LE; + format = AF_FORMAT_S16_LE; bits_per_sample = 16; m = 2; break; diff --git a/libao2/ao_macosx.c b/libao2/ao_macosx.c index b13fcac4c9..8ab0ab2b3c 100644 --- a/libao2/ao_macosx.c +++ b/libao2/ao_macosx.c @@ -47,7 +47,7 @@ #include "audio_out.h" #include "audio_out_internal.h" -#include "afmt.h" +#include "libaf/af_format.h" static ao_info_t info = { @@ -252,7 +252,7 @@ static int init(int rate,int channels,int format,int flags) if (ao->outputStreamBasicDescription.mFormatID == kAudioFormatLinearPCM) { uint32_t flags = ao->outputStreamBasicDescription.mFormatFlags; if (flags & kAudioFormatFlagIsFloat) { - ao_data.format = AFMT_FLOAT; + ao_data.format = AF_FORMAT_FLOAT_NE; } else { ao_msg(MSGT_AO,MSGL_WARN, "Unsupported audio output " "format %d. Please report this to the developer\n", diff --git a/libao2/ao_mpegpes.c b/libao2/ao_mpegpes.c index be9ad4a7f2..925d78b609 100644 --- a/libao2/ao_mpegpes.c +++ b/libao2/ao_mpegpes.c @@ -15,7 +15,7 @@ #include "audio_out.h" #include "audio_out_internal.h" -#include "afmt.h" +#include "libaf/af_format.h" #include "mp_msg.h" #include "help_mp.h" @@ -96,14 +96,14 @@ static int init(int rate,int channels,int format,int flags){ ao_data.channels=2; ao_data.outburst=2000; switch(format){ - case AFMT_S16_LE: - case AFMT_S16_BE: - case AFMT_MPEG: - case AFMT_AC3: + case AF_FORMAT_S16_LE: + case AF_FORMAT_S16_BE: + case AF_FORMAT_MPEG2: + case AF_FORMAT_AC3: ao_data.format=format; break; default: - ao_data.format=AFMT_S16_BE; + ao_data.format=AF_FORMAT_S16_BE; } retry: @@ -174,14 +174,14 @@ static int get_space(){ // return: number of bytes played static int play(void* data,int len,int flags){ // printf("\nao_mpegpes: play(%d) freq=%d\n",len,freq_id); - if(ao_data.format==AFMT_MPEG) + if(ao_data.format==AF_FORMAT_MPEG2) send_pes_packet(data,len,0x1C0,ao_data.pts); else { int i; unsigned short *s=data; // if(len>2000) len=2000; // printf("ao_mpegpes: len=%d \n",len); - if(ao_data.format==AFMT_S16_LE || ao_data.format==AFMT_AC3) + if(ao_data.format==AF_FORMAT_S16_LE || ao_data.format==AF_FORMAT_AC3) for(i=0;i>8)|(s[i]<<8); // le<->be send_lpcm_packet(data,len,0xA0,ao_data.pts,freq_id); } diff --git a/libao2/ao_nas.c b/libao2/ao_nas.c index 6f77bcbd9e..5955ac1b89 100644 --- a/libao2/ao_nas.c +++ b/libao2/ao_nas.c @@ -37,7 +37,7 @@ #include "audio_out.h" #include "audio_out_internal.h" -#include "afmt.h" +#include "libaf/af_format.h" #define NAS_FRAG_SIZE 4096 @@ -312,22 +312,22 @@ static AuDeviceID nas_find_device(AuServer *aud, int nch) static unsigned int nas_aformat_to_auformat(unsigned int *format) { switch (*format) { - case AFMT_U8: + case AF_FORMAT_U8: return AuFormatLinearUnsigned8; - case AFMT_S8: + case AF_FORMAT_S8: return AuFormatLinearSigned8; - case AFMT_U16_LE: + case AF_FORMAT_U16_LE: return AuFormatLinearUnsigned16LSB; - case AFMT_U16_BE: + case AF_FORMAT_U16_BE: return AuFormatLinearUnsigned16MSB; - case AFMT_S16_LE: + case AF_FORMAT_S16_LE: return AuFormatLinearSigned16LSB; - case AFMT_S16_BE: + case AF_FORMAT_S16_BE: return AuFormatLinearSigned16MSB; - case AFMT_MU_LAW: + case AF_FORMAT_MU_LAW: return AuFormatULAW8; default: - *format=AFMT_S16_NE; + *format=AF_FORMAT_S16_NE; return nas_aformat_to_auformat(format); } } diff --git a/libao2/ao_null.c b/libao2/ao_null.c index 59d115a400..80f3f6c351 100644 --- a/libao2/ao_null.c +++ b/libao2/ao_null.c @@ -2,7 +2,7 @@ #include #include -#include "afmt.h" +#include "libaf/af_format.h" #include "audio_out.h" #include "audio_out_internal.h" @@ -55,7 +55,7 @@ static int init(int rate,int channels,int format,int flags){ ao_data.samplerate=rate; ao_data.format=format; ao_data.bps=channels*rate; - if (format != AFMT_U8 && format != AFMT_S8) + if (format != AF_FORMAT_U8 && format != AF_FORMAT_S8) ao_data.bps*=2; buffer=0; gettimeofday(&last_tv, 0); diff --git a/libao2/ao_oss.c b/libao2/ao_oss.c index 8028835b81..7fa33e4603 100644 --- a/libao2/ao_oss.c +++ b/libao2/ao_oss.c @@ -9,14 +9,21 @@ #include #include #include -//#include #include "config.h" #include "mp_msg.h" #include "mixer.h" #include "help_mp.h" -#include "afmt.h" +#ifdef HAVE_SYS_SOUNDCARD_H +#include +#else +#ifdef HAVE_SOUNDCARD_H +#include +#endif +#endif + +#include "../libaf/af_format.h" #include "audio_out.h" #include "audio_out_internal.h" @@ -33,6 +40,86 @@ static ao_info_t info = LIBAO_EXTERN(oss) +static int format2oss(int format) +{ + switch(format) + { + case AF_FORMAT_U8: return AFMT_U8; + case AF_FORMAT_S8: return AFMT_S8; + case AF_FORMAT_U16_LE: return AFMT_U16_LE; + case AF_FORMAT_U16_BE: return AFMT_U16_BE; + case AF_FORMAT_S16_LE: return AFMT_S16_LE; + case AF_FORMAT_S16_BE: return AFMT_S16_BE; +#ifdef AFMT_S24_LE + case AF_FORMAT_U24_LE: return AFMT_U24_LE; + case AF_FORMAT_U24_BE: return AFMT_U24_BE; + case AF_FORMAT_S24_LE: return AFMT_S24_LE; + case AF_FORMAT_S24_BE: return AFMT_S24_BE; +#endif +#ifdef AFMT_S32_LE + case AF_FORMAT_U32_LE: return AFMT_U32_LE; + case AF_FORMAT_U32_BE: return AFMT_U32_BE; + case AF_FORMAT_S32_LE: return AFMT_S32_LE; + case AF_FORMAT_S32_BE: return AFMT_S32_BE; +#endif +#ifdef AFMT_FLOAT + case AF_FORMAT_FLOAT_NE: return AFMT_FLOAT; +#endif + // SPECIALS + case AF_FORMAT_MU_LAW: return AFMT_MU_LAW; + case AF_FORMAT_A_LAW: return AFMT_A_LAW; + case AF_FORMAT_IMA_ADPCM: return AFMT_IMA_ADPCM; +#ifdef AFMT_MPEG + case AF_FORMAT_MPEG2: return AFMT_MPEG; +#endif +#ifdef AFMT_AC3 + case AF_FORMAT_AC3: return AFMT_AC3; +#endif + } + printf("Unknown format: %x\n", format); + return -1; +} + +static int oss2format(int format) +{ + switch(format) + { + case AFMT_U8: return AF_FORMAT_U8; + case AFMT_S8: return AF_FORMAT_S8; + case AFMT_U16_LE: return AF_FORMAT_U16_LE; + case AFMT_U16_BE: return AF_FORMAT_U16_BE; + case AFMT_S16_LE: return AF_FORMAT_S16_LE; + case AFMT_S16_BE: return AF_FORMAT_S16_BE; +#ifdef AFMT_S24_LE + case AFMT_U24_LE: return AF_FORMAT_U24_LE; + case AFMT_U24_BE: return AF_FORMAT_U24_BE; + case AFMT_S24_LE: return AF_FORMAT_S24_LE; + case AFMT_S24_BE: return AF_FORMAT_S24_BE; +#endif +#ifdef AFMT_S32_LE + case AFMT_U32_LE: return AF_FORMAT_U32_LE; + case AFMT_U32_BE: return AF_FORMAT_U32_BE; + case AFMT_S32_LE: return AF_FORMAT_S32_LE; + case AFMT_S32_BE: return AF_FORMAT_S32_BE; +#endif +#ifdef AFMT_FLOAT + case AFMT_FLOAT: return AF_FORMAT_FLOAT_NE; +#endif + // SPECIALS + case AFMT_MU_LAW: return AF_FORMAT_MU_LAW; + case AFMT_A_LAW: return AF_FORMAT_A_LAW; + case AFMT_IMA_ADPCM: return AF_FORMAT_IMA_ADPCM; +#ifdef AFMT_MPEG + case AFMT_MPEG: return AF_FORMAT_MPEG2; +#endif +#ifdef AFMT_AC3 + case AFMT_AC3: return AF_FORMAT_AC3; +#endif + } + printf("Unknown format: %x\n", format); + return -1; +} + static char *dsp=PATH_DEV_DSP; static audio_buf_info zz; static int audio_fd=-1; @@ -57,7 +144,7 @@ static int control(int cmd,void *arg){ ao_control_vol_t *vol = (ao_control_vol_t *)arg; int fd, v, devs; - if(ao_data.format == AFMT_AC3) + if(ao_data.format == AF_FORMAT_AC3) return CONTROL_TRUE; if ((fd = open(oss_mixer_device, O_RDONLY)) > 0) @@ -95,9 +182,10 @@ static int control(int cmd,void *arg){ // return: 1=success 0=fail static int init(int rate,int channels,int format,int flags){ char *mixer_channels [SOUND_MIXER_NRDEVICES] = SOUND_DEVICE_NAMES; + int oss_format; - mp_msg(MSGT_AO,MSGL_V,"ao2: %d Hz %d chans %s\n",rate,channels, - audio_out_format_name(format)); +// mp_msg(MSGT_AO,MSGL_V,"ao2: %d Hz %d chans %s\n",rate,channels, +// audio_out_format_name(format)); if (ao_subdevice) dsp = ao_subdevice; @@ -160,32 +248,39 @@ static int init(int rate,int channels,int format,int flags){ fcntl(audio_fd, F_SETFD, FD_CLOEXEC); #endif - if(format == AFMT_AC3) { + if(format == AF_FORMAT_AC3) { ao_data.samplerate=rate; ioctl (audio_fd, SNDCTL_DSP_SPEED, &ao_data.samplerate); } ac3_retry: ao_data.format=format; - if( ioctl(audio_fd, SNDCTL_DSP_SETFMT, &ao_data.format)<0 || - ao_data.format != format) if(format == AFMT_AC3){ + oss_format=format2oss(format); + if (oss_format == -1) return 0; + if( ioctl(audio_fd, SNDCTL_DSP_SETFMT, &oss_format)<0 || + oss_format != format2oss(format)) if(format == AF_FORMAT_AC3){ mp_msg(MSGT_AO,MSGL_WARN, MSGTR_AO_OSS_CantSetAC3, dsp); #ifdef WORDS_BIGENDIAN - format=AFMT_S16_BE; + oss_format=AFMT_S16_BE; + format=AF_FORMAT_S16_BE; #else - format=AFMT_S16_LE; + oss_format=AFMT_S16_LE; + format=AF_FORMAT_S16_LE; #endif goto ac3_retry; } - mp_msg(MSGT_AO,MSGL_V,"audio_setup: sample format: %s (requested: %s)\n", - audio_out_format_name(ao_data.format), audio_out_format_name(format)); +// mp_msg(MSGT_AO,MSGL_V,"audio_setup: sample format: %s (requested: %s)\n", +// audio_out_format_name(ao_data.format), audio_out_format_name(format)); #if 0 - if(ao_data.format!=format) + if(oss_format!=format2oss(format)) mp_msg(MSGT_AO,MSGL_WARN,"WARNING! Your soundcard does NOT support %s sample format! Broken audio or bad playback speed are possible! Try with '-aop list=format'\n",audio_out_format_name(format)); #endif + + ao_data.format = oss2format(oss_format); + if (ao_data.format == -1) return 0; ao_data.channels = channels; - if(format != AFMT_AC3) { + if(format != AF_FORMAT_AC3) { // We only use SNDCTL_DSP_CHANNELS for >2 channels, in case some drivers don't have it if (ao_data.channels > 2) { if ( ioctl(audio_fd, SNDCTL_DSP_CHANNELS, &ao_data.channels) == -1 || @@ -253,7 +348,7 @@ ac3_retry: } ao_data.bps=ao_data.channels; - if(ao_data.format != AFMT_U8 && ao_data.format != AFMT_S8) + if(ao_data.format != AF_FORMAT_U8 && ao_data.format != AF_FORMAT_S8) ao_data.bps*=2; ao_data.outburst-=ao_data.outburst % ao_data.bps; // round down @@ -280,6 +375,7 @@ static void uninit(int immed){ // stop playing and empty buffers (for seeking/pause) static void reset(){ + int oss_format; uninit(1); audio_fd=open(dsp, O_WRONLY); if(audio_fd < 0){ @@ -291,8 +387,9 @@ static void reset(){ fcntl(audio_fd, F_SETFD, FD_CLOEXEC); #endif - ioctl (audio_fd, SNDCTL_DSP_SETFMT, &ao_data.format); - if(ao_data.format != AFMT_AC3) { + oss_format = format2oss(ao_data.format); + ioctl (audio_fd, SNDCTL_DSP_SETFMT, &oss_format); + if(ao_data.format != AF_FORMAT_AC3) { if (ao_data.channels > 2) ioctl (audio_fd, SNDCTL_DSP_CHANNELS, &ao_data.channels); else { diff --git a/libao2/ao_pcm.c b/libao2/ao_pcm.c index d1cf65f2a0..609f79c9f0 100644 --- a/libao2/ao_pcm.c +++ b/libao2/ao_pcm.c @@ -5,7 +5,7 @@ #include #include "bswap.h" -#include "afmt.h" +#include "libaf/af_format.h" #include "audio_out.h" #include "audio_out_internal.h" #include "mp_msg.h" @@ -89,12 +89,12 @@ static int init(int rate,int channels,int format,int flags){ bits=8; switch(format){ - case AFMT_S8: - format=AFMT_U8; - case AFMT_U8: + case AF_FORMAT_S8: + format=AF_FORMAT_U8; + case AF_FORMAT_U8: break; default: - format=AFMT_S16_LE; + format=AF_FORMAT_S16_LE; bits=16; break; } @@ -114,9 +114,9 @@ static int init(int rate,int channels,int format,int flags){ wavhdr.data_length=le2me_32(0x7ffff000); wavhdr.file_length = wavhdr.data_length + sizeof(wavhdr) - 8; - mp_msg(MSGT_AO, MSGL_INFO, MSGTR_AO_PCM_FileInfo, ao_outputfilename, - (ao_pcm_waveheader?"WAVE":"RAW PCM"), rate, - (channels > 1) ? "Stereo" : "Mono", audio_out_format_name(format)); +// mp_msg(MSGT_AO, MSGL_INFO, MSGTR_AO_PCM_FileInfo, ao_outputfilename, +// (ao_pcm_waveheader?"WAVE":"RAW PCM"), rate, +// (channels > 1) ? "Stereo" : "Mono", audio_out_format_name(format)); mp_msg(MSGT_AO, MSGL_INFO, MSGTR_AO_PCM_HintInfo); fp = fopen(ao_outputfilename, "wb"); diff --git a/libao2/ao_plugin.c b/libao2/ao_plugin.c index 357d338743..0da8959c3e 100644 --- a/libao2/ao_plugin.c +++ b/libao2/ao_plugin.c @@ -6,7 +6,7 @@ #include "mp_msg.h" #include "help_mp.h" -#include "afmt.h" +#include "libaf/af_format.h" #include "audio_out.h" #include "audio_out_internal.h" @@ -140,7 +140,7 @@ static int init(int rate,int channels,int format,int flags){ ao_plugin_local_data.format=format; ao_plugin_local_data.channels=channels; - ao_plugin_local_data.bpm=audio_out_format_bits(format); + ao_plugin_local_data.bpm=af_fmt2bits(format); ao_plugin_data.rate=rate; ao_plugin_data.channels=channels; @@ -168,7 +168,7 @@ static int init(int rate,int channels,int format,int flags){ // Calculate bps ao_plugin_local_data.bps=(float)(ao_plugin_data.rate * ao_plugin_data.channels); - ao_plugin_local_data.bps*=audio_out_format_bits(ao_plugin_data.format)/8; + ao_plugin_local_data.bps*=af_fmt2bits(ao_plugin_data.format)/8; // This should never happen but check anyway if(NULL==ao_plugin_local_data.driver) diff --git a/libao2/ao_polyp.c b/libao2/ao_polyp.c index ef072d2381..e75d05aaf4 100644 --- a/libao2/ao_polyp.c +++ b/libao2/ao_polyp.c @@ -6,7 +6,7 @@ #include "audio_out.h" #include "audio_out_internal.h" -#include "afmt.h" +#include "libaf/af_format.h" #include "config.h" #include "mp_msg.h" @@ -91,16 +91,16 @@ static int init(int rate_hz, int channels, int format, int flags) { ss.rate = rate_hz; switch (format) { - case AFMT_U8: + case AF_FORMAT_U8: ss.format = PA_SAMPLE_U8; break; - case AFMT_S16_LE: + case AF_FORMAT_S16_LE: ss.format = PA_SAMPLE_S16LE; break; - case AFMT_S16_BE: + case AF_FORMAT_S16_BE: ss.format = PA_SAMPLE_S16BE; break; - case AFMT_FLOAT: + case AF_FORMAT_FLOAT_NE: ss.format = PA_SAMPLE_FLOAT32; break; default: diff --git a/libao2/ao_sdl.c b/libao2/ao_sdl.c index 73a2c05a3d..bc2db2e258 100644 --- a/libao2/ao_sdl.c +++ b/libao2/ao_sdl.c @@ -20,7 +20,7 @@ #include "audio_out.h" #include "audio_out_internal.h" -#include "afmt.h" +#include "libaf/af_format.h" #include #include "osdep/timer.h" @@ -181,7 +181,7 @@ static int init(int rate,int channels,int format,int flags){ /* Allocate ring-buffer memory */ buffer = (unsigned char *) malloc(BUFFSIZE); - mp_msg(MSGT_AO,MSGL_INFO,MSGTR_AO_SDL_INFO, rate, (channels > 1) ? "Stereo" : "Mono", audio_out_format_name(format)); +// mp_msg(MSGT_AO,MSGL_INFO,MSGTR_AO_SDL_INFO, rate, (channels > 1) ? "Stereo" : "Mono", audio_out_format_name(format)); if(ao_subdevice) { setenv("SDL_AUDIODRIVER", ao_subdevice, 1); @@ -193,32 +193,32 @@ static int init(int rate,int channels,int format,int flags){ ao_data.format=format; ao_data.bps=channels*rate; - if(format != AFMT_U8 && format != AFMT_S8) + if(format != AF_FORMAT_U8 && format != AF_FORMAT_S8) ao_data.bps*=2; /* The desired audio format (see SDL_AudioSpec) */ switch(format) { - case AFMT_U8: + case AF_FORMAT_U8: aspec.format = AUDIO_U8; break; - case AFMT_S16_LE: + case AF_FORMAT_S16_LE: aspec.format = AUDIO_S16LSB; break; - case AFMT_S16_BE: + case AF_FORMAT_S16_BE: aspec.format = AUDIO_S16MSB; break; - case AFMT_S8: + case AF_FORMAT_S8: aspec.format = AUDIO_S8; break; - case AFMT_U16_LE: + case AF_FORMAT_U16_LE: aspec.format = AUDIO_U16LSB; break; - case AFMT_U16_BE: + case AF_FORMAT_U16_BE: aspec.format = AUDIO_U16MSB; break; default: aspec.format = AUDIO_S16LSB; - ao_data.format = AFMT_S16_LE; + ao_data.format = AF_FORMAT_S16_LE; mp_msg(MSGT_AO,MSGL_WARN,MSGTR_AO_SDL_UnsupportedAudioFmt, format); } @@ -256,22 +256,22 @@ void callback(void *userdata, Uint8 *stream, int len); userdata is the pointer s switch(obtained.format) { case AUDIO_U8 : - ao_data.format = AFMT_U8; + ao_data.format = AF_FORMAT_U8; break; case AUDIO_S16LSB : - ao_data.format = AFMT_S16_LE; + ao_data.format = AF_FORMAT_S16_LE; break; case AUDIO_S16MSB : - ao_data.format = AFMT_S16_BE; + ao_data.format = AF_FORMAT_S16_BE; break; case AUDIO_S8 : - ao_data.format = AFMT_S8; + ao_data.format = AF_FORMAT_S8; break; case AUDIO_U16LSB : - ao_data.format = AFMT_U16_LE; + ao_data.format = AF_FORMAT_U16_LE; break; case AUDIO_U16MSB : - ao_data.format = AFMT_U16_BE; + ao_data.format = AF_FORMAT_U16_BE; break; default: mp_msg(MSGT_AO,MSGL_WARN,MSGTR_AO_SDL_UnsupportedAudioFmt, obtained.format); diff --git a/libao2/ao_win32.c b/libao2/ao_win32.c index ba004c7b26..e589ced8c1 100644 --- a/libao2/ao_win32.c +++ b/libao2/ao_win32.c @@ -23,7 +23,7 @@ #include #include -#include "afmt.h" +#include "libaf/af_format.h" #include "audio_out.h" #include "audio_out_internal.h" #include "mp_msg.h" @@ -149,21 +149,21 @@ static int init(int rate,int channels,int format,int flags) int i; switch(format){ - case AFMT_AC3: - case AFMT_S24_LE: - case AFMT_S16_LE: - case AFMT_S8: + case AF_FORMAT_AC3: + case AF_FORMAT_S24_LE: + case AF_FORMAT_S16_LE: + case AF_FORMAT_S8: break; default: mp_msg(MSGT_AO, MSGL_V,"ao_win32: format %s not supported defaulting to Signed 16-bit Little-Endian\n",audio_out_format_name(format)); - format=AFMT_S16_LE; + format=AF_FORMAT_S16_LE; } //fill global ao_data ao_data.channels=channels; ao_data.samplerate=rate; ao_data.format=format; ao_data.bps=channels*rate; - if(format != AFMT_U8 && format != AFMT_S8) + if(format != AF_FORMAT_U8 && format != AF_FORMAT_S8) ao_data.bps*=2; if(ao_data.buffersize==-1) { @@ -179,7 +179,7 @@ static int init(int rate,int channels,int format,int flags) wformat.Format.cbSize = (channels>2)?sizeof(WAVEFORMATEXTENSIBLE)-sizeof(WAVEFORMATEX):0; wformat.Format.nChannels = channels; wformat.Format.nSamplesPerSec = rate; - if(format == AFMT_AC3) + if(format == AF_FORMAT_AC3) { wformat.Format.wFormatTag = WAVE_FORMAT_DOLBY_AC3_SPDIF; wformat.Format.wBitsPerSample = 16; @@ -208,7 +208,7 @@ static int init(int rate,int channels,int format,int flags) mp_msg(MSGT_AO, MSGL_ERR,"ao_win32: format not supported switching to default\n"); ao_data.channels = wformat.Format.nChannels = 2; ao_data.samplerate = wformat.Format.nSamplesPerSec = 44100; - ao_data.format = AFMT_S16_LE; + ao_data.format = AF_FORMAT_S16_LE; ao_data.bps=ao_data.channels * ao_data.samplerate*2; wformat.Format.wBitsPerSample=16; wformat.Format.wFormatTag=WAVE_FORMAT_PCM; diff --git a/libao2/audio_out.c b/libao2/audio_out.c index 97691bc2d7..0bd37ad555 100644 --- a/libao2/audio_out.c +++ b/libao2/audio_out.c @@ -4,7 +4,6 @@ #include "config.h" #include "audio_out.h" -#include "afmt.h" #include "mp_msg.h" #include "help_mp.h" @@ -187,6 +186,7 @@ ao_functions_t* init_best_audio_out(char** ao_list,int use_plugin,int rate,int c audio_out_plugin.control(AOCONTROL_SET_PLUGIN_DRIVER,audio_out); audio_out=&audio_out_plugin; } +// if(audio_out->control(AOCONTROL_QUERY_FORMAT, (int)format) == CONTROL_TRUE) if(audio_out->init(rate,channels,format,flags)) return audio_out; // success! } diff --git a/libao2/audio_plugin.h b/libao2/audio_plugin.h index 170efea901..1936e19d36 100644 --- a/libao2/audio_plugin.h +++ b/libao2/audio_plugin.h @@ -45,7 +45,7 @@ extern ao_plugin_cfg_t ao_plugin_cfg; // Configuration defaults #define CFG_DEFAULTS { \ NULL, \ - AFMT_S16_LE, \ + AF_FORMAT_S16_LE, \ 0, \ 48000, \ 101, \ diff --git a/libao2/pl_delay.c b/libao2/pl_delay.c index e39489505f..ed1693431c 100644 --- a/libao2/pl_delay.c +++ b/libao2/pl_delay.c @@ -12,7 +12,7 @@ #include "audio_out.h" #include "audio_plugin.h" #include "audio_plugin_internal.h" -#include "afmt.h" +#include "libaf/af_format.h" static ao_info_t info = { @@ -65,7 +65,7 @@ static int init(){ // Tell ao_plugin how much this plugin adds to the overall time delay time_delay=-1*(float)ao_plugin_cfg.pl_delay_len/((float)pl_delay.channels*(float)pl_delay.rate); - if(pl_delay.format != AFMT_U8 && pl_delay.format != AFMT_S8) + if(pl_delay.format != AF_FORMAT_U8 && pl_delay.format != AF_FORMAT_S8) time_delay/=2; ao_plugin_data.delay_fix+=time_delay; diff --git a/libao2/pl_eq.c b/libao2/pl_eq.c index bb30470d91..1165b8033d 100644 --- a/libao2/pl_eq.c +++ b/libao2/pl_eq.c @@ -24,7 +24,7 @@ #include "audio_out.h" #include "audio_plugin.h" #include "audio_plugin_internal.h" -#include "afmt.h" +#include "libaf/af_format.h" #include "eq.h" static ao_info_t info = @@ -122,7 +122,7 @@ static int init(){ float F[KM] = CF; // Check input format - if(ao_plugin_data.format != AFMT_S16_NE){ + if(ao_plugin_data.format != AF_FORMAT_S16_NE){ fprintf(stderr,"[pl_eq] Input audio format not yet supported. \n"); return 0; } diff --git a/libao2/pl_extrastereo.c b/libao2/pl_extrastereo.c index 845a984a15..9f3404d5fe 100644 --- a/libao2/pl_extrastereo.c +++ b/libao2/pl_extrastereo.c @@ -19,7 +19,7 @@ #include "audio_out.h" #include "audio_plugin.h" #include "audio_plugin_internal.h" -#include "afmt.h" +#include "libaf/af_format.h" static ao_info_t info = { "Extra stereo plugin", @@ -57,7 +57,7 @@ static int control(int cmd,void *arg){ // return: 1=success 0=fail static int init(){ switch(ao_plugin_data.format){ - case(AFMT_S16_NE): + case(AF_FORMAT_S16_NE): break; default: fprintf(stderr,"[pl_extrastereo] Audio format not yet suported \n"); @@ -87,7 +87,7 @@ static void reset(){ static int play(){ switch(pl_extrastereo.format){ - case(AFMT_S16_NE): { + case(AF_FORMAT_S16_NE): { int16_t* data=(int16_t*)ao_plugin_data.data; int len=ao_plugin_data.len / 2; // 16 bits samples diff --git a/libao2/pl_format.c b/libao2/pl_format.c index 87b5bc8720..46ddaaa6a6 100644 --- a/libao2/pl_format.c +++ b/libao2/pl_format.c @@ -16,7 +16,7 @@ #include "audio_out.h" #include "audio_plugin.h" #include "audio_plugin_internal.h" -#include "afmt.h" +#include "libaf/af_format.h" static ao_info_t info = { @@ -75,29 +75,30 @@ static int control(int cmd,void *arg){ // open & setup audio device // return: 1=success 0=fail static int init(){ + char buf1[128], buf2[128]; // Sheck input format switch(ao_plugin_data.format){ - case(AFMT_U8): + case(AF_FORMAT_U8): pl_format.in=LE|B08|US; break; - case(AFMT_S8): + case(AF_FORMAT_S8): pl_format.in=LE|B08|SI; break; - case(AFMT_S16_LE): + case(AF_FORMAT_S16_LE): pl_format.in=LE|B16|SI; break; - case(AFMT_S16_BE): + case(AF_FORMAT_S16_BE): pl_format.in=BE|B16|SI; break; - case(AFMT_U16_LE): + case(AF_FORMAT_U16_LE): pl_format.in=LE|B16|US; break; - case(AFMT_U16_BE): + case(AF_FORMAT_U16_BE): pl_format.in=BE|B16|US; break; - case(AFMT_S32_LE): + case(AF_FORMAT_S32_LE): pl_format.in=LE|B32|SI; break; - case(AFMT_S32_BE): + case(AF_FORMAT_S32_BE): pl_format.in=BE|B32|SI; break; - case(AFMT_IMA_ADPCM): - case(AFMT_MU_LAW): - case(AFMT_A_LAW): - case(AFMT_MPEG): - case(AFMT_AC3): + case(AF_FORMAT_IMA_ADPCM): + case(AF_FORMAT_MU_LAW): + case(AF_FORMAT_A_LAW): + case(AF_FORMAT_MPEG2): + case(AF_FORMAT_AC3):