Skip to content

Commit c8a2d81

Browse files
authored
dispose FfiHandle immediately (#531)
1 parent 5b1a979 commit c8a2d81

File tree

4 files changed

+4
-5
lines changed

4 files changed

+4
-5
lines changed

livekit-rtc/livekit/rtc/_ffi_client.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,5 @@ def request(self, req: proto_ffi.FfiRequest) -> proto_ffi.FfiResponse:
241241
resp_data = ctypes.string_at(resp_ptr, resp_len.value)
242242
resp = proto_ffi.FfiResponse()
243243
resp.ParseFromString(resp_data)
244-
245-
FfiHandle(handle)
244+
FfiHandle(handle).dispose()
246245
return resp

livekit-rtc/livekit/rtc/audio_frame.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def _from_owned_info(owned_info: proto_audio.OwnedAudioFrameBuffer) -> "AudioFra
9090
size = info.num_channels * info.samples_per_channel
9191
cdata = (ctypes.c_int16 * size).from_address(info.data_ptr)
9292
data = bytearray(cdata)
93-
FfiHandle(owned_info.handle.id)
93+
FfiHandle(owned_info.handle.id).dispose()
9494
return AudioFrame(data, info.sample_rate, info.num_channels, info.samples_per_channel)
9595

9696
def _proto_info(self) -> proto_audio.AudioFrameBufferInfo:

livekit-rtc/livekit/rtc/room.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -811,7 +811,7 @@ def _on_room_event(self, event: proto_room.RoomEvent):
811811
).contents
812812

813813
data = bytes(native_data)
814-
FfiHandle(owned_buffer_info.handle.id)
814+
FfiHandle(owned_buffer_info.handle.id).dispose()
815815
rparticipant = cast(
816816
RemoteParticipant,
817817
self._retrieve_remote_participant(packet.participant_identity),

livekit-rtc/livekit/rtc/video_frame.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def _from_owned_info(owned_info: proto_video.OwnedVideoBuffer) -> "VideoFrame":
105105
type=info.type,
106106
data=data,
107107
)
108-
FfiHandle(owned_info.handle.id)
108+
FfiHandle(owned_info.handle.id).dispose()
109109
return frame
110110

111111
def _proto_info(self) -> proto_video.VideoBufferInfo:

0 commit comments

Comments
 (0)