+ //To ensure we don't overflow the sample buffer, but still send it large chunks of data
+ //(to make the packet sends to the session efficient) only call process group after
+ //a large number of samples have been seen.
+ //cbuf_wrptr counts slices, so shift right by 2 to create a worst case x4 multiple ratio of
+ //cbuf_wrptr value to the depth of the sample buffer.
+ //Likely we could use the max rle value of 640 but 1024 gives some extra room.
+ //Also do a simple check of rlecnt>2000 since that is a reasonable minimal value to send to the session
+ if ((rlecnt>=2000)
+ ||((rlecnt + ((d->cbuf_wrptr)<<2))) > (d->sample_buf_size - 1024)) {
+ sr_spew("D4 preoverflow wrptr %d bufsize %d rlecnt %d\n\r",d->cbuf_wrptr,d->sample_buf_size,rlecnt);
+ rle_memset(d, rlecnt);
+ process_group(sdi, d, d->cbuf_wrptr);
+ rlecnt=0;
+ }
+
+ }//while rdptr < wrptr