- m = outOutputData->mBuffers[i].mDataByteSize / sizeof(float);
- dest = outOutputData->mBuffers[i].mData;
- while (m > 0) {
- if ((n = powd->from->remaining) <= 0) {
- PARA_INFO_LOG("%s", "buffer underrun\n");
- /* no more bytes in the current read buffer! */
- while ((n = powd->from->remaining) <= 0)
- /* wait for the results */
- usleep(2000);
- }
-// PARA_INFO_LOG("buf %p: n = %ld, m= %ld\n", powd->from->buffer, n, m);
- /*
- * we dump what we can. In fact, just the necessary
- * should be sufficient
- */
- if (n > m)
- n = m;
- memcpy(dest, powd->from->ptr, n * sizeof(float));
- dest += n;
- /* remember all done work */
- m -= n;
- powd->from->ptr += n;
- if ((powd->from->remaining -= n) <= 0)
- powd->from = powd->from->next;
+ void *dest = abl->mBuffers[i].mData;
+ size_t sz = abl->mBuffers[i].mDataByteSize, samples, bytes;
+
+ samples_want = sz / wn->min_iqs;
+ while (samples_want > 0) {
+ char *buf;
+ btr_merge(powd->callback_btrn, wn->min_iqs);
+ samples_have = btr_next_buffer(powd->callback_btrn, &buf) / wn->min_iqs;
+ //PARA_INFO_LOG("i: %d want %zu samples to addr %p, have: %zu\n", i, samples_want,
+ // dest, samples_have);
+ samples = PARA_MIN(samples_have, samples_want);
+ if (samples == 0)
+ break;
+ bytes = samples * wn->min_iqs;
+ memcpy(dest, buf, bytes);
+ btr_consume(powd->callback_btrn, bytes);
+ samples_want -= samples;
+ dest += bytes;