Repository navigation
fix(rtc): return no frames from AudioResampler.flush() when nothing is buffered - #938
Open
ANDROIDHASSAN wants to merge 1 commit into
Open
ANDROIDHASSAN wants to merge 1 commit into
ANDROIDHASSAN wants to merge 1 commit into
Conversation
…s buffered The FFI flush reply carries a non-zero output_ptr with size 0 when the resampler has no data left, so the ptr check never matched and flush() returned one 0-sample frame. Check the size instead, as the docstring promises an empty list.
ANDROIDHASSAN
requested review from
changt,
cloudwebrtc,
lukasIO and
xianshijing-lk
as code owners
November 12, 2026 14:08
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem:
AudioResampler.flush()returns[AudioFrame(samples_per_channel=0)]instead of[]when nothing is buffered, both on a fresh resampler and on a second flush. The docstring says "The list may be empty if no output data remains". The FFI flush reply setsoutput_ptrto the (non-null) buffer address even whensizeis 0, so theif not output_ptrcheck never matches.push()gets ptr 0 for empty output, so it is not affected.Callers that forward flushed frames, such as
RecognizeStream.flush()in livekit-agents, then pass a 0-sample frame on to the provider.Fix: check
sizeinstead ofoutput_ptr. One line.Tests:
test_flush_with_nothing_buffered_returns_no_framesintests/rtc/test_resampler.py. Run against livekit-rtc 1.2.1's FFI library:mainit fails:Left contains one more item: rtc.AudioFrame(sample_rate=16000, num_channels=1, samples_per_channel=0, ...). A fresh flush and a second flush both return the empty frame.ruff checkandruff format --checkpass on both files. Includes alivekit-rtcpatch changeset.Scope:
flush()still does not read the reply'serrorfield the waypush()does. That path can't be reached from a test, so it is left out. The non-null pointer for empty output comes from the Rust side; this change only makes the Python check match the length it actually reads.