# HG changeset patch # User anders # Date 1007468906 0 # Node ID 28f2ebcb5c9581677911ab6a2ac7e51a9ffa8b45 # Parent ea7c1bfc4391cd35122a2fb1c76ac8aa5525ff47 Format plugin now with working switch statements diff -r ea7c1bfc4391 -r 28f2ebcb5c95 libao2/pl_format.c --- a/libao2/pl_format.c Tue Dec 04 12:23:27 2001 +0000 +++ b/libao2/pl_format.c Tue Dec 04 12:28:26 2001 +0000 @@ -60,12 +60,12 @@ 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 @@ 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 @@ 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 @@ // 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 @@ // 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 @@ 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 @@ 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; }