INNER CODE UNIT · C
used
Cateners/tiny_container · app/src/main/cpp/tiny_audio_jni.c:73
uint32_t used = w - rd;
/*
* Latency guard: if the ringbuffer has accumulated too much data,
* the consumer (AAudio) has fallen behind. Skip old frames so the
* listener doesn't experience growing end-to-end delay.
*/
if (used > RING_LATENCY_LIMIT) {
uint32_t new_rd = w - RING_LATENCY_LIMIT;
LOGI("ring: latency guard skip %u bytes", new_rd - rd);
atomic_store_explicit(&r->read_idx, new_rd, memory_order_release);
rd = new_rd;
used = RING_LATENCY_LIMIT;
}
uint32_t space = RING_SIZE - used;
if (n > space) n = space;
if (!n) return 0;