Skip to content

Commit

Permalink
less aggressive flush #1159 #1167
Browse files Browse the repository at this point in the history
  • Loading branch information
mrlt8 committed May 4, 2024
1 parent d34cc42 commit ddb76e2
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions app/wyzecam/iotc.py
Original file line number Diff line number Diff line change
Expand Up @@ -489,15 +489,18 @@ def _video_frame_slow(self, frame_info) -> Optional[bool]:

frame_ts = float(f"{frame_info.timestamp}.{frame_info.timestamp_ms}")
gap = time.time() - frame_ts
if not frame_info.is_keyframe and gap > 2 and not self._sleep_buffer:

if not frame_info.is_keyframe and gap > 3 and not self._sleep_buffer:
logger.warning("[video] super slow")
self.clear_buffer()

return True

if not frame_info.is_keyframe and gap >= 0.5:
logger.debug(f"[video] slow {gap=}")
self.flush_pipe("audio")
self._sleep_buffer += gap
return True

return

self.frame_ts = frame_ts

Expand Down Expand Up @@ -565,7 +568,7 @@ def flush_pipe(self, pipe_type: str = "audio"):
logger.debug(f"flushing {pipe_type}")

try:
with io.open(fifo, "rb", buffering=8192) as pipe:
with io.open(fifo, "rb") as pipe:
set_non_blocking(pipe.fileno())
while data_read := pipe.read(8192):
logger.debug(f"Flushed {len(data_read)} from {pipe_type} pipe")
Expand Down

0 comments on commit ddb76e2

Please sign in to comment.