@@ -65,7 +65,7 @@ def __init__(
6565 num_channels : int = 1 ,
6666 frame_size_ms : int | None = None ,
6767 noise_cancellation : Optional [NoiseCancellationOptions | FrameProcessor [AudioFrame ]] = None ,
68- noise_cancellation_leave_open : bool = False ,
68+ auto_close_noise_cancellation : bool = True ,
6969 ** kwargs : Any ,
7070 ) -> None :
7171 """Initialize an `AudioStream` instance.
@@ -82,9 +82,9 @@ def __init__(
8282 noise_cancellation (Optional[NoiseCancellationOptions | FrameProcessor[AudioFrame]], optional):
8383 If noise cancellation is used, pass a `NoiseCancellationOptions` or `FrameProcessor[AudioFrame]` instance
8484 created by the noise cancellation module.
85- noise_cancellation_leave_open (bool):
86- When the audio stream closes, leaves the FrameProcessor in an unclosed state so it
87- can be used with another AudioStream.
85+ auto_close_noise_cancellation (bool):
86+ When the audio stream closes, should the FrameProcessor's close method be run? If
87+ False, then the frame processor can be reused with another AudioStream.
8888
8989 Example:
9090 ```python
@@ -117,13 +117,13 @@ def __init__(
117117 self ._audio_filter_module : str | None = None
118118 self ._audio_filter_options : dict [str , Any ] | None = None
119119 self ._processor : FrameProcessor [AudioFrame ] | None = None
120- self ._processor_leave_open = False
120+ self ._processor_auto_close = True
121121 if isinstance (noise_cancellation , NoiseCancellationOptions ):
122122 self ._audio_filter_module = noise_cancellation .module_id
123123 self ._audio_filter_options = noise_cancellation .options
124124 elif isinstance (noise_cancellation , FrameProcessor ):
125125 self ._processor = noise_cancellation
126- self ._processor_leave_open = noise_cancellation_leave_open
126+ self ._processor_auto_close = auto_close_noise_cancellation
127127
128128 self ._task = self ._loop .create_task (self ._run ())
129129 self ._task .add_done_callback (task_done_logger )
@@ -153,7 +153,7 @@ def from_participant(
153153 num_channels : int = 1 ,
154154 frame_size_ms : int | None = None ,
155155 noise_cancellation : Optional [NoiseCancellationOptions | FrameProcessor [AudioFrame ]] = None ,
156- noise_cancellation_leave_open : bool = False ,
156+ auto_close_noise_cancellation : bool = False ,
157157 ) -> AudioStream :
158158 """Create an `AudioStream` from a participant's audio track.
159159
@@ -191,7 +191,7 @@ def from_participant(
191191 num_channels = num_channels ,
192192 frame_size_ms = frame_size_ms ,
193193 noise_cancellation = noise_cancellation ,
194- noise_cancellation_leave_open = noise_cancellation_leave_open ,
194+ auto_close_noise_cancellation = auto_close_noise_cancellation ,
195195 )
196196
197197 @classmethod
@@ -205,7 +205,7 @@ def from_track(
205205 num_channels : int = 1 ,
206206 frame_size_ms : int | None = None ,
207207 noise_cancellation : Optional [NoiseCancellationOptions | FrameProcessor [AudioFrame ]] = None ,
208- noise_cancellation_leave_open : bool = False ,
208+ auto_close_noise_cancellation : bool = False ,
209209 ) -> AudioStream :
210210 """Create an `AudioStream` from an existing audio track.
211211
@@ -218,7 +218,7 @@ def from_track(
218218 noise_cancellation (Optional[NoiseCancellationOptions | FrameProcessor[AudioFrame]], optional):
219219 If noise cancellation is used, pass a `NoiseCancellationOptions` or `FrameProcessor[AudioFrame]` instance
220220 created by the noise cancellation module.
221- noise_cancellation_leave_open (bool):
221+ auto_close_noise_cancellation (bool):
222222 When the audio stream closes, leaves the FrameProcessor in an unclosed state so it
223223 can be used with another AudioStream.
224224
@@ -242,7 +242,7 @@ def from_track(
242242 num_channels = num_channels ,
243243 frame_size_ms = frame_size_ms ,
244244 noise_cancellation = noise_cancellation ,
245- noise_cancellation_leave_open = noise_cancellation_leave_open ,
245+ auto_close_noise_cancellation = auto_close_noise_cancellation ,
246246 )
247247
248248 def __del__ (self ) -> None :
@@ -323,7 +323,7 @@ async def aclose(self) -> None:
323323 self ._track ._unregister_audio_stream (self )
324324 self ._ffi_handle .dispose ()
325325 await self ._task
326- if self ._processor is not None and not self ._processor_leave_open :
326+ if self ._processor is not None and self ._processor_auto_close :
327327 self ._processor ._close ()
328328
329329 def _is_event (self , e : proto_ffi .FfiEvent ) -> bool :
0 commit comments