app: replace audio send polling with blocking queue.get
Deterministic wake on data arrival instead of 5ms sleep loop. Reduces CPU wake-ups and eliminates up to 5ms of added latency.
This commit is contained in:
@@ -676,13 +676,11 @@ class TuimbleApp(App):
|
|||||||
|
|
||||||
@work(thread=True)
|
@work(thread=True)
|
||||||
def _audio_send_loop(self) -> None:
|
def _audio_send_loop(self) -> None:
|
||||||
"""Poll capture queue and send encoded frames to server."""
|
"""Send captured audio frames to the server."""
|
||||||
while self._client.connected:
|
while self._client.connected:
|
||||||
frame = self._audio.get_capture_frame()
|
frame = self._audio.get_capture_frame(timeout=0.02)
|
||||||
if frame is not None:
|
if frame is not None:
|
||||||
self._client.send_audio(frame)
|
self._client.send_audio(frame)
|
||||||
else:
|
|
||||||
time.sleep(0.005)
|
|
||||||
|
|
||||||
# -- channel tree --------------------------------------------------------
|
# -- channel tree --------------------------------------------------------
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user