From 6ab94ae409dc48056503d753746581311c95345d Mon Sep 17 00:00:00 2001 From: anders Date: Tue, 4 Dec 2001 12:28:26 +0000 Subject: Format plugin now with working switch statements git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@3310 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libao2/pl_format.c | 103 +++++++++++++++++++++-------------------------------- 1 file changed, 41 insertions(+), 62 deletions(-) (limited to 'libao2') diff --git a/libao2/pl_format.c b/libao2/pl_format.c index b64004b2dd..932b2e014a 100644 --- a/libao2/pl_format.c +++ b/libao2/pl_format.c @@ -60,12 +60,12 @@ static int control(int cmd,int arg){ switch(cmd){ case AOCONTROL_PLUGIN_SET_LEN: if(pl_format.data) - uninit(); + free(pl_format.data); pl_format.len = ao_plugin_data.len; - if(ao_plugin_data.data) - free(ao_plugin_data.data); pl_format.data=(void*)malloc(ao_plugin_data.len); - ao_plugin_data.len=(int)(((double)ao_plugin_data.len)*pl_format.sz_mult); + if(!pl_format.data) + return CONTROL_ERROR; + ao_plugin_data.len=(int)(((double)ao_plugin_data.len)/pl_format.sz_mult); return CONTROL_OK; } return -1; @@ -97,7 +97,7 @@ static int init(){ case(AFMT_A_LAW): case(AFMT_MPEG): case(AFMT_AC3): - printf("[pl_format] Audio format not yet suported \n"); + printf("[pl_format] Input audio format not yet suported \n"); return 0; default: printf("[pl_format] Unrecognised input audio format\n"); //This can not happen .... @@ -126,7 +126,7 @@ static int init(){ case(AFMT_A_LAW): case(AFMT_MPEG): case(AFMT_AC3): - printf("[pl_format] Audio format not yet suported \n"); + printf("[pl_format] Output audio format not yet suported \n"); return 0; default: printf("[pl_format] Unrecognised audio output format\n"); @@ -141,7 +141,7 @@ static int init(){ // We are changing the format ao_plugin_data.format=ao_plugin_cfg.pl_format_type; - // Perhaps the buffer size + // And perhaps the buffer size pl_format.sz_mult=1; if((pl_format.in&NBITS_MASK) > (pl_format.out&NBITS_MASK)) pl_format.sz_mult/=(double)(1<<((pl_format.in&NBITS_MASK)-(pl_format.out&NBITS_MASK))); @@ -161,9 +161,7 @@ static void uninit(){ // empty buffers static void reset(){ - int i = 0; - for(i=0;i>(pl_format.in&NBITS_MASK); ao_plugin_data.len=(int)(((double)ao_plugin_data.len)*=pl_format.sz_mult); - ao_plugin_data.len; - + // Change to little endian (Is this true for sun ?) if((pl_format.in&END_MASK)!=LE){ switch(pl_format.in&NBITS_MASK){ @@ -186,8 +183,8 @@ static int play(){ s=((uint16_t*)in_data)[i]; ((uint16_t*)in_data)[i]=(uint16_t)(((s&0x00FF)<<8) | (s&0xFF00)>>8); } - break; } + break; case(B32):{ register uint32_t s; for(i=1;i>8) | ((s&0xFF000000)>>24)); } - break; } + break; } } - // Change signed/unsigned if((pl_format.in&SIGN_MASK) != (pl_format.out&SIGN_MASK)){ - switch(pl_format.in&NBITS_MASK){ - case(B08):{ + switch((pl_format.in&NBITS_MASK)){ + case(B08): switch(pl_format.in&SIGN_MASK){ - case(US):{ + case(US): for(i=0;i>8); break; - } - case(B32):{ + case(B32): for(i=1;i>24); break; - } - case(B16):{ + case(B16): for(i=1;i>16); break; } - } - } + break; } } - // Switch to the correct endainess (agiain the problem with sun?) if((pl_format.out&END_MASK)!=LE){ switch(pl_format.in&NBITS_MASK){ @@ -311,8 +291,8 @@ static int play(){ s=((uint16_t*)out_data)[i]; ((uint16_t*)out_data)[i]=(uint16_t)(((s&0x00FF)<<8) | (s&0xFF00)>>8); } - break; } + break; case(B32):{ register uint32_t s; for(i=1;i>8) | ((s&0xFF000000)>>24)); } - break; } + break; } } - ao_plugin_data.data=out_data; return 1; } -- cgit v1.2.3