Use high precision scheduler to send RTP packets#52
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #52 +/- ##
==========================================
- Coverage 94.59% 92.50% -2.10%
==========================================
Files 24 24
Lines 1721 1788 +67
==========================================
+ Hits 1628 1654 +26
- Misses 93 134 +41 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR updates outbound RTP audio pacing in AudioCall.send_audio to use absolute-time scheduling rather than incremental asyncio.sleep, aiming for more consistent 20ms packet spacing.
Changes:
- Replace per-packet
asyncio.sleeppacing withsched.scheduler-based absolute scheduling. - Add a
send_audio_schedulerfield onAudioCall. - Update the pacing unit test to validate scheduler-based timing.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
voip/audio.py |
Switches RTP packet pacing implementation to a scheduler/executor approach and introduces a scheduler field on AudioCall. |
tests/test_audio.py |
Reworks the pacing test to mock sched.scheduler and assert scheduled timing intervals. |
You can also share your feedback on Copilot code review. Take the survey.
There was a problem hiding this comment.
Pull request overview
This PR changes outbound RTP audio pacing in AudioCall.send_audio() to use a sched.scheduler-based approach (run in an executor) rather than per-packet asyncio.sleep() delays, aiming for more precise packet timing.
Changes:
- Add a per-call
sched.schedulerinstance toAudioCall. - Rework
AudioCall.send_audio()to enqueue packet sends at absolute times and run the scheduler in a thread viarun_in_executor. - Update the pacing unit test to assert
enterabs()scheduling intervals instead of capturedasyncio.sleep()delays.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
voip/audio.py |
Introduces sched.scheduler pacing and executes scheduled sends via a threadpool executor. |
tests/test_audio.py |
Updates pacing test to validate scheduler enterabs() spacing. |
You can also share your feedback on Copilot code review. Take the survey.
There was a problem hiding this comment.
Pull request overview
This PR updates outbound RTP audio transmission to use event-loop scheduling (call_later) instead of asyncio.sleep-based pacing, enabling outbound audio to be cancelled/preempted (notably for AI/agent calls).
Changes:
- Replace per-packet
asyncio.sleeppacing inAudioCall.send_audio()with acall_later-driven scheduler and add outbound-cancellation support. - Add AgentCall hooks to cancel outbound speech when user speech/transcriptions arrive.
- Update and extend unit tests to reflect the new scheduling/cancellation behavior.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
voip/audio.py |
Introduces timer-handle based outbound packet scheduling and cancellation API. |
voip/ai.py |
Cancels outbound audio on transcription and adds speech/silence-based cancellation timers. |
tests/test_audio.py |
Updates send-audio pacing assertions and adds cancellation/preemption tests. |
You can also share your feedback on Copilot code review. Take the survey.
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
No description provided.