livekit / rust-sdks

LiveKit realtime and server SDKs for Rust
https://livekit.io
Apache License 2.0
185 stars 44 forks source link

fix: simplified `enable_queue` field for AudioSource. #360

Closed cloudwebrtc closed 2 months ago

cloudwebrtc commented 2 months ago

after several days of hard debugging, I had to remove the call of self.sys_handle.on_captured_frame from captured_frame. I tried to break the audio frame in Unity AudioSource into 10ms frames, or directly pass all buffers into captured_frame. However, due to some call jitter, the encoded sound jittered and the delay accumulated. I guess some lock contention caused it, but I couldn't find the real reason.

So the current way that works perfectly is to use enable_queue to control whether to execute the interval.tick() timer wait inside spawn, and whether to insert a silent frame when po_rx is empty.

I will resubmit the patch when I find a better solution