From 2495e0418ee827b2d7bed8c67b21a51790b5db0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20Monnom?= Date: Fri, 27 Sep 2024 20:36:22 -0700 Subject: [PATCH] fix invalid data len in the audioresampler (#266) --- livekit-rtc/livekit/rtc/audio_resampler.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/livekit-rtc/livekit/rtc/audio_resampler.py b/livekit-rtc/livekit/rtc/audio_resampler.py index 1d8c0adf..c821d3b8 100644 --- a/livekit-rtc/livekit/rtc/audio_resampler.py +++ b/livekit-rtc/livekit/rtc/audio_resampler.py @@ -93,7 +93,7 @@ def push(self, data: bytearray | AudioFrame) -> list[AudioFrame]: Raises: Exception: If there is an error during resampling. """ - bdata = data if isinstance(data, bytearray) else data.data + bdata = data if isinstance(data, bytearray) else data.data.cast("b") req = proto_ffi.FfiRequest() req.push_sox_resampler.resampler_handle = self._ffi_handle.handle @@ -144,8 +144,8 @@ def flush(self) -> list[AudioFrame]: if not resp.flush_sox_resampler.output_ptr: return [] - cdata = (ctypes.c_int8 * resp.push_sox_resampler.size).from_address( - resp.push_sox_resampler.output_ptr + cdata = (ctypes.c_int8 * resp.flush_sox_resampler.size).from_address( + resp.flush_sox_resampler.output_ptr ) output_data = bytearray(cdata) return [