Skip to content

fix(room-io): preserve audio frame processors across stream transitions#5455

Closed
nightcityblade wants to merge 2 commits intolivekit:mainfrom
nightcityblade:fix/issue-5448
Closed

fix(room-io): preserve audio frame processors across stream transitions#5455
nightcityblade wants to merge 2 commits intolivekit:mainfrom
nightcityblade:fix/issue-5448

Conversation

@nightcityblade
Copy link
Copy Markdown

Fixes #5448

Summary

  • stop _ParticipantInputStream._close_stream() from closing the active frame processor during ordinary stream transitions
  • close replaced per-track processors inside _ParticipantAudioInputStream._create_stream() and close orphaned processors when a track disappears without replacement
  • add a regression test covering a direct rtc.FrameProcessor passed via noise_cancellation so it survives the initial subscription and still closes during final teardown

Testing

  • .venv/bin/python -m pytest tests/test_room_io_noise_cancellation.py tests/test_room_io_teardown.py
  • .venv/bin/ruff check livekit-agents/livekit/agents/voice/room_io/_input.py tests/test_room_io_noise_cancellation.py tests/test_room_io_teardown.py

@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


nightcityblade seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

devin-ai-integration[bot]

This comment was marked as resolved.

@nightcityblade
Copy link
Copy Markdown
Author

Thanks, good catch. I restored the selector-created processor cleanup for participant changes that do not immediately create a replacement stream, including and switching to a participant with no available track yet. I also added regression coverage for both paths and reran the targeted room I/O noise cancellation tests.

@longcw
Copy link
Copy Markdown
Contributor

longcw commented Apr 16, 2026

thanks for the pr! If you don't mind I created a separate one with some cleanup and a different impl in #5467

@nightcityblade
Copy link
Copy Markdown
Author

Thanks for the heads-up, and thanks for putting together the follow-up PR with the cleanup and alternate implementation. That sounds good to me. Since you've got #5467 moving forward, I'm happy to defer to that one.

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.

AudioInputOptions.noise_cancellation: FrameProcessor killed by premature _close() in _close_stream() — processes zero frames

3 participants