style: apply rustfmt to establish clean baseline before refactor
Pre-refactor baseline state: - 79 lib tests + 3 integration tests pass (1 integration test #[ignore]) - cargo clippy --all-targets -- -D warnings clean - cargo build --release clean No semantic changes; only rustfmt drift correction across 6 files.
This commit is contained in:
+13
-21
@@ -273,9 +273,7 @@ impl StatePortal {
|
||||
bitrate_rx,
|
||||
encoder_resolution_rx,
|
||||
)?;
|
||||
let duplicate_count = std::sync::Arc::new(
|
||||
std::sync::atomic::AtomicU64::new(0),
|
||||
);
|
||||
let duplicate_count = std::sync::Arc::new(std::sync::atomic::AtomicU64::new(0));
|
||||
let duplicate_count_for_thread = duplicate_count.clone();
|
||||
let handle = std::thread::Builder::new()
|
||||
.name("wl-webrtc-encode".into())
|
||||
@@ -370,11 +368,13 @@ impl StatePortal {
|
||||
// capture channel depth. Oracle audit 2026-06-28: previously hardcoded
|
||||
// (0, 0), which silently zeroed two real diagnostic fields.
|
||||
let total_dropped = self.cap.dropped_count();
|
||||
self.stats.set_pipewire_dropped(total_dropped, self.pw_dropped_prev);
|
||||
self.stats
|
||||
.set_pipewire_dropped(total_dropped, self.pw_dropped_prev);
|
||||
self.pw_dropped_prev = total_dropped;
|
||||
// capture queue depth is real; encoded side has no exposed depth — the
|
||||
// encoder thread publishes timings only, not a frame queue length.
|
||||
self.stats.set_queue_depths(self.cap.capture_queue_depth(), 0);
|
||||
self.stats
|
||||
.set_queue_depths(self.cap.capture_queue_depth(), 0);
|
||||
if let Some(ref enc_thread) = self.enc_thread {
|
||||
while let Ok(timing) = enc_thread.timing_rx.try_recv() {
|
||||
self.stats.record_encode_thread(
|
||||
@@ -517,9 +517,8 @@ impl StatePortal {
|
||||
// frames_rgb pointer is a valid AVBufferRef owned by enc, and `frame` is the
|
||||
// PipeWire-formatted PwDmaBufFrame whose metadata the function reads directly.
|
||||
// See that function's own SAFETY contract.
|
||||
let mut vaapi_frame = unsafe {
|
||||
avhw::import_dma_buf_to_vaapi(enc.frames_rgb().as_ptr(), &frame)
|
||||
}?;
|
||||
let mut vaapi_frame =
|
||||
unsafe { avhw::import_dma_buf_to_vaapi(enc.frames_rgb().as_ptr(), &frame) }?;
|
||||
|
||||
let import_us = t_import_start.elapsed().as_micros() as u64;
|
||||
|
||||
@@ -550,9 +549,8 @@ impl StatePortal {
|
||||
} else if let Some(import) = self.enc_import.as_mut() {
|
||||
// SAFETY: same contract as the enc branch above — frames_rgb owned by
|
||||
// import, `frame` carries the PipeWire DMA-BUF metadata.
|
||||
let mut vaapi_frame = unsafe {
|
||||
avhw::import_dma_buf_to_vaapi(import.frames_rgb().as_ptr(), &frame)
|
||||
}?;
|
||||
let mut vaapi_frame =
|
||||
unsafe { avhw::import_dma_buf_to_vaapi(import.frames_rgb().as_ptr(), &frame) }?;
|
||||
// SAFETY: vaapi_frame is the valid AVFrame returned above; pts is plain i64.
|
||||
unsafe {
|
||||
(*vaapi_frame.as_mut_ptr()).pts = pts;
|
||||
@@ -842,8 +840,7 @@ fn webrtc_thread_loop(
|
||||
.unwrap_or(0.0);
|
||||
// Compute capture-to-send age on the sending thread so the
|
||||
// frame_age stat stays accurate when batch-drained later.
|
||||
let age_ms =
|
||||
Some(enc_frame.capture_time.elapsed().as_secs_f64() * 1000.0);
|
||||
let age_ms = Some(enc_frame.capture_time.elapsed().as_secs_f64() * 1000.0);
|
||||
last_send = Some(std::time::Instant::now());
|
||||
let _ = sent_gap_tx.try_send((gap_ms, age_ms));
|
||||
}
|
||||
@@ -854,16 +851,14 @@ fn webrtc_thread_loop(
|
||||
match webrtc_rx.recv_timeout(timeout) {
|
||||
Ok(enc_frame) => {
|
||||
if wrtc.is_connected() {
|
||||
if let Err(e) = wrtc.write_h264_frame(&enc_frame.data, enc_frame.pts_ticks)
|
||||
{
|
||||
if let Err(e) = wrtc.write_h264_frame(&enc_frame.data, enc_frame.pts_ticks) {
|
||||
tracing::debug!("WebRTC write frame error: {e}");
|
||||
}
|
||||
frames_sent = frames_sent.saturating_add(1);
|
||||
let gap_ms = last_send
|
||||
.map(|l| l.elapsed().as_secs_f64() * 1000.0)
|
||||
.unwrap_or(0.0);
|
||||
let age_ms =
|
||||
Some(enc_frame.capture_time.elapsed().as_secs_f64() * 1000.0);
|
||||
let age_ms = Some(enc_frame.capture_time.elapsed().as_secs_f64() * 1000.0);
|
||||
last_send = Some(std::time::Instant::now());
|
||||
let _ = sent_gap_tx.try_send((gap_ms, age_ms));
|
||||
}
|
||||
@@ -1200,10 +1195,7 @@ mod tests {
|
||||
fn select_resolution_keeps_720p_when_bwe_sufficient() {
|
||||
let fps = 30;
|
||||
let bitrate_720 = resolution_bitrate_bps(1280, 720, fps);
|
||||
assert_eq!(
|
||||
select_resolution(1280, 720, bitrate_720, fps),
|
||||
(1280, 720)
|
||||
);
|
||||
assert_eq!(select_resolution(1280, 720, bitrate_720, fps), (1280, 720));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user