From fd233b45f32f30e5aaaa5fc522e822e6f25e470c Mon Sep 17 00:00:00 2001 From: David Zhao Date: Mon, 10 Nov 2025 00:00:22 -0800 Subject: [PATCH] fix crash when zero byte data is pushed into resampler when a 0 byte array is pushed into AudioResampler, it raises: ValueError: Buffer size too small (0 instead of at least 1 bytes) --- livekit-rtc/livekit/rtc/audio_resampler.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/livekit-rtc/livekit/rtc/audio_resampler.py b/livekit-rtc/livekit/rtc/audio_resampler.py index a8559b87..4d4c02c5 100644 --- a/livekit-rtc/livekit/rtc/audio_resampler.py +++ b/livekit-rtc/livekit/rtc/audio_resampler.py @@ -94,6 +94,8 @@ def push(self, data: bytearray | AudioFrame) -> list[AudioFrame]: Exception: If there is an error during resampling. """ bdata = data if isinstance(data, bytearray) else data.data.cast("b") + if not bdata: + return [] req = proto_ffi.FfiRequest() req.push_sox_resampler.resampler_handle = self._ffi_handle.handle