# HG changeset patch # User anders # Date 1007468417 0 # Node ID 4a5d56e897354dad0b0f07cbd7d5136e478ff6d9 # Parent f1ba704d7b40b6dec57be0d6e6b1a3341be2c100 correced memory deallocation bug and erors in comments diff -r f1ba704d7b40 -r 4a5d56e89735 libao2/pl_delay.c --- a/libao2/pl_delay.c Tue Dec 04 09:49:44 2001 +0000 +++ b/libao2/pl_delay.c Tue Dec 04 12:20:17 2001 +0000 @@ -1,8 +1,8 @@ -/* This is a null audio out plugin it doesnt't really do anything - useful but serves an example of how audio plugins work. It delays - the output signal by the nuber of samples set by aop_delay n - where n is the number of bytes. - */ +/* Audio out plugin it doesnt't really do anything useful but serves + an example of how audio plugins work. It delays the output signal + by the nuber of samples set by delay=n where n is the number of + bytes. +*/ #define PLUGIN #include @@ -32,7 +32,6 @@ int rate; // local data rate int channels; // local number of channels int format; // local format - } pl_delay_t; static pl_delay_t pl_delay={NULL,NULL,0,0,0,0}; @@ -42,9 +41,11 @@ switch(cmd){ case AOCONTROL_PLUGIN_SET_LEN: if(pl_delay.data) - uninit(); + free(pl_delay.data); pl_delay.len = ao_plugin_data.len; pl_delay.data=(void*)malloc(ao_plugin_data.len); + if(!pl_delay.data) + return CONTROL_ERROR; return CONTROL_OK; } return -1; @@ -54,11 +55,12 @@ // return: 1=success 0=fail static int init(){ int i=0; - float time_delay; // The number of tsamples this plugin delays the output data - /* if the output format of any of the below parameters differs from + float time_delay; // The time in [s] this plugin delays the output data + + /* If the output format of any of the below parameters differs from what is give it should be changed. See ao_plugin init() */ pl_delay.rate=ao_plugin_data.rate; - pl_delay.channels=ao_plugin_data.channels+1; //0=mono 1=stereo + pl_delay.channels=ao_plugin_data.channels; //1=mono 2=stereo pl_delay.format=ao_plugin_data.format; // Tell ao_plugin how much this plugin adds to the overall time delay @@ -67,11 +69,13 @@ time_delay/=2; ao_plugin_data.delay_fix+=time_delay; + // Create buffer for the delayed data pl_delay.delay=(void*)malloc(ao_plugin_cfg.pl_delay_len); if(!pl_delay.delay) return 0; - for(i=0;i