Skip to content

test(rtc): cover native receive PCM and stream cleanup - #928

Draft
theomonnom wants to merge 1 commit into
mainfrom
codex/audio-native-batching-tests
Draft

theomonnom wants to merge 1 commit into
mainfrom
codex/audio-native-batching-tests

Conversation

@theomonnom

@theomonnom theomonnom commented Nov 8, 2026 •

Copy link
Copy Markdown
Member

TL;DR: Add exact-PCM and repeated-close regression tests for native audio receive batching.

  • CPU impact: 0% production runtime change; this PR only adds tests.
  • More voice sessions per core/machine: 0 directly. These tests help validate the optimization PRs; they do not add capacity themselves.

Add integration tests for the native receive batching change through the public Python RTC API. The tests load the actual FFI selected by LIVEKIT_LIB_PATH and pass against both stock and patched libraries; this PR changes no Python RTC production code.

Twelve combinations check exact PCM order and frame metadata at 8/24/48 kHz, mono/stereo, and 7/10/20/50 ms requested frames. A repeated-close test verifies that the stream task finishes and FFI subscriptions return to baseline over 20 iterations. Sources, tracks, streams, and collection tasks are explicitly closed/disposed.

Validation: all 13 cases passed against stock and final patched FFI, including a fresh run from this branch. The 31 existing RTC lifecycle/queue tests also passed during the accompanying investigation. Changed-file Ruff lint/format checks passed.

To exercise an alternate native library:

LIVEKIT_LIB_PATH=/absolute/path/to/liblivekit_ffi.so \
  python -m pytest livekit-rtc/tests/test_audio_native_batching.py -q -o asyncio_mode=auto

These local-source checks do not need an SFU. They cover exact sample delivery and cleanup, not network jitter, acoustic interruption latency, or production session capacity.

Related draft PRs: receive batching, Opus AVX2, Python log filtering, inline VAD.

@github-actions

github-actions Bot commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

👋 This PR has no changeset. If it should be released, add a markdown file under .changeset/ (any name, e.g. .changeset/fix-token-parsing.md):

---
"livekit-rtc": patch
---

Short description of the change, used in the release notes.
  • Packages: livekit-rtc, livekit-api, livekit-protocol (one line per package)
  • Types: patch, minor, major, patch-rc, minor-rc, major-rc, next-rc, promote

If this change doesn't need a release (docs, CI, tests), you can ignore this comment.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant