From 221f1de759fb650cca7cf18f3b304a908ee78248 Mon Sep 17 00:00:00 2001 From: Daisuke Murase Date: Sat, 28 Dec 2024 08:23:20 -0800 Subject: [PATCH] make async for future flexibility --- examples/video-stream/audio_wave.py | 4 ++-- examples/video-stream/video_play.py | 4 ++-- livekit-rtc/livekit/rtc/audio_source.py | 2 +- livekit-rtc/livekit/rtc/video_source.py | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/examples/video-stream/audio_wave.py b/examples/video-stream/audio_wave.py index 37d0a86b..b00c31aa 100644 --- a/examples/video-stream/audio_wave.py +++ b/examples/video-stream/audio_wave.py @@ -296,8 +296,8 @@ async def main(room: rtc.Room, room_name: str): finally: audio_task.cancel() await av_sync.aclose() - audio_source.close() - video_source.close() + await audio_source.aclose() + await video_source.aclose() if __name__ == "__main__": diff --git a/examples/video-stream/video_play.py b/examples/video-stream/video_play.py index ea4d8ce3..b15e1ccc 100644 --- a/examples/video-stream/video_play.py +++ b/examples/video-stream/video_play.py @@ -181,8 +181,8 @@ async def _push_frames( finally: await streamer.aclose() await av_sync.aclose() - audio_source.close() - video_source.close() + await audio_source.aclose() + await video_source.aclose() if __name__ == "__main__": diff --git a/livekit-rtc/livekit/rtc/audio_source.py b/livekit-rtc/livekit/rtc/audio_source.py index ac54462e..839203d8 100644 --- a/livekit-rtc/livekit/rtc/audio_source.py +++ b/livekit-rtc/livekit/rtc/audio_source.py @@ -176,7 +176,7 @@ def _release_waiter(self) -> None: self._q_size = 0.0 self._join_fut = None - def close(self) -> None: + async def aclose(self) -> None: """Close the audio source This method cleans up resources associated with the audio source. diff --git a/livekit-rtc/livekit/rtc/video_source.py b/livekit-rtc/livekit/rtc/video_source.py index 96114b29..5ae58f66 100644 --- a/livekit-rtc/livekit/rtc/video_source.py +++ b/livekit-rtc/livekit/rtc/video_source.py @@ -43,5 +43,5 @@ def capture_frame( req.capture_video_frame.timestamp_us = timestamp_us FfiClient.instance.request(req) - def close(self) -> None: + async def aclose(self) -> None: self._ffi_handle.dispose()