Skip to content

fix(voip): increase live audio buffer headroom - #280

Open
mmhospedagem wants to merge 1 commit into
vinikjkkj:masterfrom
mmhospedagem:codex/fix-voip-live-buffer
Open

fix(voip): increase live audio buffer headroom#280
mmhospedagem wants to merge 1 commit into
vinikjkkj:masterfrom
mmhospedagem:codex/fix-voip-live-buffer

Conversation

@mmhospedagem

@mmhospedagem mmhospedagem commented Sep 10, 2026

Copy link
Copy Markdown

Summary

  • raise the live-audio high-water threshold from 200 ms to 450 ms
  • raise the maximum retained buffer from 500 ms to 750 ms
  • update overflow and oversized-chunk regression expectations

Why

Short upstream stalls and scheduling jitter could exhaust the previous 500 ms ceiling and drop recent speech before it reached the call. The larger ceiling remains bounded while providing more headroom.

Validation

  • focused ESLint and Prettier: passed
  • @zapo-js/voip tests: 72/72 passed
  • @zapo-js/voip typecheck: passed
  • @zapo-js/voip build (CJS and ESM): passed

Review in cubic

@github-actions github-actions Bot added the fix Bug fix label Sep 10, 2026
@coderabbitai

coderabbitai Bot commented Sep 10, 2026

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 21 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 2 included reviews currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: f1c5a2ec-4426-465c-a114-c96ecf73a81c

📥 Commits

Reviewing files that changed from the base of the PR and between 40a9af5 and ff42fc5.

📒 Files selected for processing (3)
  • .changeset/soft-owls-buffer.md
  • packages/voip/src/media/WaAudioEngine.ts
  • packages/voip/src/media/__tests__/audio-engine.test.ts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 3 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="packages/voip/src/media/__tests__/audio-engine.test.ts">

<violation number="1" location="packages/voip/src/media/__tests__/audio-engine.test.ts:75">
P2: The 'keeps only the tail of an oversized chunk' test no longer exercises the truncation path. With the new 750 ms cap (12000 samples at 16 kHz), a 10000-sample chunk no longer exceeds extMaxBuffer, so the `incoming.length > this.extMaxBuffer` branch in feedExternalAudio is never entered. Feed a chunk larger than 12000 samples (e.g. 20000) and assert the resulting level (750 ms) so the oversized-chunk regression test still covers its intended code path.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

const level = engine.feedExternalAudio(new Float32Array(10_000))
assert.equal(level, 500)
assert.equal(engine.getLiveBufferMs(), 500)
assert.equal(level, 625)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: The 'keeps only the tail of an oversized chunk' test no longer exercises the truncation path. With the new 750 ms cap (12000 samples at 16 kHz), a 10000-sample chunk no longer exceeds extMaxBuffer, so the incoming.length > this.extMaxBuffer branch in feedExternalAudio is never entered. Feed a chunk larger than 12000 samples (e.g. 20000) and assert the resulting level (750 ms) so the oversized-chunk regression test still covers its intended code path.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At packages/voip/src/media/__tests__/audio-engine.test.ts, line 75:

<comment>The 'keeps only the tail of an oversized chunk' test no longer exercises the truncation path. With the new 750 ms cap (12000 samples at 16 kHz), a 10000-sample chunk no longer exceeds extMaxBuffer, so the `incoming.length > this.extMaxBuffer` branch in feedExternalAudio is never entered. Feed a chunk larger than 12000 samples (e.g. 20000) and assert the resulting level (750 ms) so the oversized-chunk regression test still covers its intended code path.</comment>

<file context>
@@ -63,17 +63,17 @@ test('feedExternalAudio caps the live buffer and drops oldest on overflow', () =
     const level = engine.feedExternalAudio(new Float32Array(10_000))
-    assert.equal(level, 500)
-    assert.equal(engine.getLiveBufferMs(), 500)
+    assert.equal(level, 625)
+    assert.equal(engine.getLiveBufferMs(), 625)
 })
</file context>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix Bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant