|Okay, it sounds like you've got several problems that I'm not really going to be able to solve quickly for you, but I'll give you some pointers :
1. It sounds like you've got problems with your buffer start/end points. Check that you can take data in and send it back out to the soundcard at 48kHz without any degradation before you start worrying about downsampling and doing uLaw encoding.
2. You need to low pass filter before you do the decimation. The routine you posted isn't doing this - it's just giving you a weighted average of every 6 samples which is completely different. It's actually best done in two stages - LPF the buffer in place (corner freqency just above 4kHz), then decimate using the routine that I posted. The filtering is probably best done with a biquad IIR filter - you'll probably get away with a 2nd order LPF filter at 5kHz for what you're doing. To implement the IIR filter, do a search on the web - that's a big topic in itself.
3. If I were you I'd do all the intermediate calculation in floating point and only convert back to fixed point at the last minute. There's relatively little performance hit in Windows and it helps avoid some hideous problems that you can encounter with fixed-point IIR filtering.