int64_t t;
#endif
- ilast = rate->ilast;
-
istart = ibuf;
iend = ibuf + *isamp;
return;
}
- while (obuf < oend) {
+ /* without input samples, there's nothing to do */
+ if (ibuf >= iend) {
+ *osamp = 0;
+ return;
+ }
- /* Safety catch to make sure we have input samples. */
- if (ibuf >= iend) {
- break;
- }
+ ilast = rate->ilast;
- /* read as many input samples so that ipos > opos */
+ while (true) {
+ /* read as many input samples so that ipos > opos */
while (rate->ipos <= (rate->opos >> 32)) {
ilast = *ibuf++;
rate->ipos++;
- /* if ipos overflow, there is a infinite loop */
- if (rate->ipos == 0xffffffff) {
- rate->ipos = 1;
- rate->opos = rate->opos & 0xffffffff;
- }
/* See if we finished the input buffer yet */
if (ibuf >= iend) {
goto the_end;
}
}
+ /* make sure that the next output sample can be written */
+ if (obuf >= oend) {
+ break;
+ }
+
icur = *ibuf;
+ /* wrap ipos and opos around long before they overflow */
+ if (rate->ipos >= 0x10001) {
+ rate->ipos = 1;
+ rate->opos &= 0xffffffff;
+ }
+
/* interpolate */
#ifdef FLOAT_MIXENG
#ifdef RECIPROCAL