Skip to content

Commit 2495e04

Browse files
authored
fix invalid data len in the audioresampler (#266)
1 parent 119f0b5 commit 2495e04

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

livekit-rtc/livekit/rtc/audio_resampler.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ def push(self, data: bytearray | AudioFrame) -> list[AudioFrame]:
9393
Raises:
9494
Exception: If there is an error during resampling.
9595
"""
96-
bdata = data if isinstance(data, bytearray) else data.data
96+
bdata = data if isinstance(data, bytearray) else data.data.cast("b")
9797

9898
req = proto_ffi.FfiRequest()
9999
req.push_sox_resampler.resampler_handle = self._ffi_handle.handle
@@ -144,8 +144,8 @@ def flush(self) -> list[AudioFrame]:
144144
if not resp.flush_sox_resampler.output_ptr:
145145
return []
146146

147-
cdata = (ctypes.c_int8 * resp.push_sox_resampler.size).from_address(
148-
resp.push_sox_resampler.output_ptr
147+
cdata = (ctypes.c_int8 * resp.flush_sox_resampler.size).from_address(
148+
resp.flush_sox_resampler.output_ptr
149149
)
150150
output_data = bytearray(cdata)
151151
return [

0 commit comments

Comments
 (0)