export class AudioQueue {
    capacity;
    maxAgeMs;
    frames = [];
    staleDrops = 0;
    overflowDrops = 0;
    constructor(capacity = 24, maxAgeMs = 1500) {
        this.capacity = capacity;
        this.maxAgeMs = maxAgeMs;
    }
    push(frame, now) { this.dropStale(now); if (this.frames.length === this.capacity) {
        this.frames.shift();
        this.overflowDrops++;
    } this.frames.push(frame); }
    take(now) { this.dropStale(now); return this.frames.shift(); }
    get size() { return this.frames.length; }
    dropStale(now) { while (this.frames.length && now - this.frames[0].createdAt > this.maxAgeMs) {
        this.frames.shift();
        this.staleDrops++;
    } }
}
