INNER CODE UNIT · C

rd

Cateners/tiny_container · app/src/main/cpp/tiny_audio_jni.c:72

    uint32_t rd = atomic_load_explicit(&r->read_idx,  memory_order_acquire);
    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;

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…