mirror of
https://github.com/openai/codex.git
synced 2026-11-27 23:31:09 +00:00
Connect voice-host RTP audio to speaker playback (#43248)
## Why The voice host drained incoming RTP packets without playing them. Route received audio through decoding and speaker output while preserving speaker suppression boundaries. ## What changed - Add a GStreamer pipeline with RTP jitter buffering, Opus decoding, conversion, and resampling into the native speaker sink. - Rebuild playout when the speaker is re-enabled, reject packets received before the new pipeline started, and discard queued audio and echo references on speaker transitions while preserving capture history. - Limit each receive pass to 64 packets so incoming media cannot indefinitely delay audio controls. - Prevent retired sink failures from failing a new speaker generation, and retain the last coherent playback delay estimate during callback contention. ## Testing Add tests for real Opus playback and stale packet rejection, combined microphone mute and speaker suppression, retired sink failures, delay contention, and echo-reference reset without losing capture history. GitOrigin-RevId: c91c94a2ba2347ac98af4e7fd1dc331ae766cc45
This commit is contained in:
1 parent
9daf7d22ca
commit
a9896da3fe
17 files changed
+713
-39
No files matched your search
@@ -81,6 +81,67 @@ fn enqueue(worker: &CaptureWorker, samples: usize, generation: u64, at: Instant)
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn combined_mute_and_suppression_cancel_old_speaker_and_capture_work() {
|
||||
let buffers = Arc::new(Buffers::new(
|
||||
/*input_rate*/ 48_000, /*output_rate*/ 48_000,
|
||||
));
|
||||
let port = super::super::playback::PlaybackPort::new(buffers.clone(), /*rate*/ 48_000);
|
||||
let mut worker = CaptureWorker {
|
||||
buffers: buffers.clone(),
|
||||
processor: processing::Processor::new(
|
||||
/*input_rate*/ 48_000, /*output_rate*/ 48_000,
|
||||
)
|
||||
.unwrap(),
|
||||
pending: VecDeque::new(),
|
||||
};
|
||||
worker
|
||||
.set_controls(AudioControls {
|
||||
microphone_muted: false,
|
||||
speaker_suppressed: false,
|
||||
})
|
||||
.unwrap();
|
||||
worker.pending.push_back(crate::audio_track::EncodedAudio {
|
||||
data: vec![1],
|
||||
at: Instant::now(),
|
||||
});
|
||||
// A failed speaker transition must not start microphone reset first.
|
||||
buffers.speaker.store(u64::MAX, Ordering::Release);
|
||||
assert!(
|
||||
worker
|
||||
.set_controls(AudioControls {
|
||||
microphone_muted: true,
|
||||
speaker_suppressed: false,
|
||||
})
|
||||
.is_err()
|
||||
);
|
||||
assert_eq!(
|
||||
(
|
||||
buffers.speaker.load(Ordering::Acquire),
|
||||
buffers.microphone.load(Ordering::Acquire),
|
||||
worker.pending.len(),
|
||||
),
|
||||
(u64::MAX, 2, 1)
|
||||
);
|
||||
buffers.speaker.store(/*val*/ 2, Ordering::Release);
|
||||
let writer = port.writer();
|
||||
worker
|
||||
.set_controls(AudioControls {
|
||||
microphone_muted: true,
|
||||
speaker_suppressed: true,
|
||||
})
|
||||
.unwrap();
|
||||
assert_eq!(
|
||||
(
|
||||
buffers.speaker.load(Ordering::Acquire),
|
||||
buffers.microphone.load(Ordering::Acquire),
|
||||
worker.pending.len(),
|
||||
writer.write(&[0; 4]),
|
||||
),
|
||||
(3, 3, 0, Err("speaker writer cancelled"))
|
||||
);
|
||||
}
|
||||
|
||||
async fn receive_capture(
|
||||
worker: &mut CaptureWorker,
|
||||
local: &mut Transport,
|
||||
|
||||
Reference in new issue
Block a user