Skip to content

Commit

Permalink
reduce sleep time for audio thread #388
Browse files Browse the repository at this point in the history
  • Loading branch information
mrlt8 committed Dec 27, 2023
1 parent 9b918b6 commit 69c9974
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions app/wyzecam/iotc.py
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ def recv_bridge_data(self) -> Iterator[bytes]:

have_key_frame = False
self.frame_ts = time.time()
while self.should_stream():
while self.should_stream(sleep=self.sleep_interval):
if not self._received_first_frame(have_key_frame):
have_key_frame = True
continue
Expand Down Expand Up @@ -487,7 +487,7 @@ 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 gap > 10:
logger.warning("\n\n[video] super slow\n\n")
logger.warning("[video] super slow")
self.clear_local_buffer()

if gap >= 0.5:
Expand All @@ -509,9 +509,8 @@ def _handle_frame_error(self, err_no: int) -> None:

raise tutk.TutkError(err_no)

def should_stream(self) -> bool:
time.sleep(self.sleep_interval)

def should_stream(self, sleep: float = 0.01) -> bool:
time.sleep(sleep)
return (
self.state == WyzeIOTCSessionState.AUTHENTICATION_SUCCEEDED
and self.stream_state.value > 1
Expand All @@ -529,9 +528,6 @@ def valid_frame_size(self) -> set[int]:
return {self.preferred_frame_size, int(os.getenv("IGNORE_RES", alt))}

def sync_camera_time(self):
if self.substream:
return

with self.iotctrl_mux() as mux:
mux.send_ioctl(tutk_protocol.K10092SetCameraTime())

Expand Down

0 comments on commit 69c9974

Please sign in to comment.