codex: fix CI failure on PR #16805

Keep the first realtime audio frame from being dropped during WebRTC startup.

Also give the realtime test server a tiny flush window before it closes the data channel so the last scripted events land reliably.

Co-authored-by: Codex <noreply@openai.com>
This commit is contained in:
Ahmed Ibrahim
2026-04-05 10:44:06 -07:00
co-authored by Codex
parent 5d5305c5d4
commit 99f72e27ae
2 changed files with 8 additions and 0 deletions
@@ -65,6 +65,7 @@ const REALTIME_AUDIO_CHANNELS: u16 = 1;
const REALTIME_AUDIO_PACKET_SAMPLES: usize = 480;
const REALTIME_AUDIO_PACKET_DURATION: Duration = Duration::from_millis(20);
const REALTIME_DATA_CHANNEL_OPEN_TIMEOUT: Duration = Duration::from_secs(10);
const REALTIME_AUDIO_TRACK_BINDING_SETTLE_TIME: Duration = Duration::from_millis(250);
const OPUS_MAX_PACKET_BYTES: usize = 4_000;
const OPUS_MAX_DECODED_SAMPLES_PER_CHANNEL: usize = 2_880;
@@ -601,6 +602,11 @@ async fn connect_webrtc_transport(
})?
.map_err(|_| ApiError::Stream("realtime WebRTC data channel did not open".to_string()))?;
// `TrackLocalStaticSample::write_sample()` silently drops samples until the RTP sender has
// finished binding after negotiation. Give webrtc-rs a short grace period so the first user
// audio frame is not discarded during startup.
tokio::time::sleep(REALTIME_AUDIO_TRACK_BINDING_SETTLE_TIME).await;
info!(
calls_url = %calls_url,
"realtime WebRTC session connected"