- /* update the avg tail if needed */
- while(bm->avg_sampleacc>bm->avg_sampledesired){
- int samples=
- ci->blocksizes[bm->queue_actual[bm->avg_tail]&0x80000000UL?1:0]>>1;
- for(i=0;i<bm->queue_bins;i++)
- bm->avg_binacc[i]-=LACING_ADJUST(bm->queue_binned[bins*bm->avg_tail+i]);
- bm->avg_sampleacc-=samples;
- bm->avg_tail++;
- if(bm->avg_tail>=bm->queue_size)bm->avg_tail=0;
- }
-
- /* update the avg center */
- if(bm->avg_centeracc>desired_center){
- /* choose the new average floater */
- double upper=floater_interpolate(bm,vi,bi->queue_avgmax);
- double lower=floater_interpolate(bm,vi,bi->queue_avgmin);
- double new=bi->avgfloat_initial,slew;
- int bin;
-
- if(upper>0. && upper<new)new=upper;
- if(lower<bi->avgfloat_minimum)
- lower=bi->avgfloat_minimum;
- if(lower>new)new=lower;
-
- slew=new-bm->avgfloat;
-
- if(slew<bi->avgfloat_downhyst || slew>bi->avgfloat_uphyst){
- if(slew<bi->avgfloat_downslew_max)
- new=bm->avgfloat+bi->avgfloat_downslew_max;
- if(slew>bi->avgfloat_upslew_max)
- new=bm->avgfloat+bi->avgfloat_upslew_max;
-
- bm->avgfloat=new;
+ if(bm->avg_sampleacc>bm->avg_sampledesired || eofflag){
+
+ /* update the avg tail if needed */
+ while(bm->avg_sampleacc>bm->avg_sampledesired){
+ int samples=
+ ci->blocksizes[bm->queue_actual[bm->avg_tail]&0x80000000UL?1:0]>>1;
+ for(i=0;i<bm->queue_bins;i++)
+ bm->avg_binacc[i]-=LACING_ADJUST(bm->queue_binned[bins*bm->avg_tail+i]);
+ bm->avg_sampleacc-=samples;
+ bm->avg_tail++;
+ if(bm->avg_tail>=bm->queue_size)bm->avg_tail=0;