Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,9 @@ def on_playback_finished(
self._reset_pause_state()

async def capture_frame(self, frame: rtc.AudioFrame) -> None:
if self.next_in_chain:
await self.next_in_chain.capture_frame(frame)

await super().capture_frame(frame)

if self.__recording_io.recording:
Expand All @@ -431,9 +434,6 @@ async def capture_frame(self, frame: rtc.AudioFrame) -> None:

self.__acc_frames.append(frame)

if self.next_in_chain:
await self.next_in_chain.capture_frame(frame)

def flush(self) -> None:
super().flush()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -507,17 +507,15 @@ def __init__(
)
self._next_in_chain: io.AudioOutput = next_in_chain # redefined for better typing
self._synchronizer = synchronizer
self._capturing = False
self._pushed_duration: float = 0.0

async def capture_frame(self, frame: rtc.AudioFrame) -> None:
# using barrier() on capture should be sufficient, flush() must not be called if
# capture_frame isn't completed
await self._synchronizer.barrier()

self._capturing = True
await super().capture_frame(frame)
await self._next_in_chain.capture_frame(frame) # passthrough audio
await super().capture_frame(frame)
self._pushed_duration += frame.duration

if not self._synchronizer.enabled:
Expand Down Expand Up @@ -545,12 +543,10 @@ def flush(self) -> None:
self._synchronizer.rotate_segment()
return

self._capturing = False
self._synchronizer._impl.end_audio_input()

def clear_buffer(self) -> None:
self._next_in_chain.clear_buffer()
self._capturing = False

# this is going to be automatically called by the next_in_chain
def on_playback_finished(
Expand Down
Loading