diff --git a/src/avhw/encode.rs b/src/avhw/encode.rs index a420e73..d7b6adb 100644 --- a/src/avhw/encode.rs +++ b/src/avhw/encode.rs @@ -173,7 +173,7 @@ impl SwEncEncode { 0, self.enc_height as i32, (*self.yuv_frame).data.as_ptr() as *mut *mut u8, - (*self.yuv_frame).linesize.as_ptr() as *const i32, + (*self.yuv_frame).linesize.as_ptr(), ); if scaled < 0 { bail!("sws_scale failed for software encoder: {scaled}"); diff --git a/src/avhw/hardware.rs b/src/avhw/hardware.rs index 0c37f07..90aef9f 100644 --- a/src/avhw/hardware.rs +++ b/src/avhw/hardware.rs @@ -17,6 +17,10 @@ pub struct EncState { enc_video: ff::codec::encoder::video::Video, frames_rgb: AvHwFrameCtx, video_filter: ff::filter::Graph, + // Root AVHWDeviceContext, kept for ownership. Each consumer (encoder, + // filter graph, frames ctx) already holds its own ref_clone(); this + // field is never read after `new()` but must outlive those clones. + #[allow(dead_code)] hw_device_ctx: AvHwDevCtx, octx: ff::format::context::Output, starting_timestamp: Option, diff --git a/src/bin/vaapi_import_bench.rs b/src/bin/vaapi_import_bench.rs index 09371bd..cbfde5d 100644 --- a/src/bin/vaapi_import_bench.rs +++ b/src/bin/vaapi_import_bench.rs @@ -587,11 +587,11 @@ fn run_cpu_pipeline( ffi::sws_scale( sws_ctx.0, (*sw_frame).data.as_ptr() as *const *const u8, - (*sw_frame).linesize.as_ptr() as *const i32, + (*sw_frame).linesize.as_ptr(), 0, (*sw_frame).height, (*encoder.yuv_frame).data.as_ptr() as *mut *mut u8, - (*encoder.yuv_frame).linesize.as_ptr() as *const i32, + (*encoder.yuv_frame).linesize.as_ptr(), ); } let scale_us = t_scale.elapsed().as_micros() as u64; @@ -744,11 +744,11 @@ fn run_gpu_pipeline( ffi::sws_scale( format_ctx.0, (*sw_nv12).data.as_ptr() as *const *const u8, - (*sw_nv12).linesize.as_ptr() as *const i32, + (*sw_nv12).linesize.as_ptr(), 0, (*sw_nv12).height, (*encoder.yuv_frame).data.as_ptr() as *mut *mut u8, - (*encoder.yuv_frame).linesize.as_ptr() as *const i32, + (*encoder.yuv_frame).linesize.as_ptr(), ); } let format_us = t_format.elapsed().as_micros() as u64; diff --git a/src/cap_portal.rs b/src/cap_portal.rs index 056eb99..cca2cad 100644 --- a/src/cap_portal.rs +++ b/src/cap_portal.rs @@ -139,6 +139,10 @@ pub struct CapPortal { frame_rx: Receiver, event_rx: Receiver, pw_thread: Option>, + // Kept alive for CapPortal's whole lifetime: ashpd caches a zbus::Connection + // in a process-global OnceCell and hangs if the owning runtime drops first + // (see AGENTS.md). Never read after `new()`; only its Drop ordering matters. + #[allow(dead_code)] rt: Runtime, pw_dropped: Arc, } @@ -154,7 +158,6 @@ struct PwThreadCtx { shutdown_read: OwnedFd, pw_fd: OwnedFd, node_id: u32, - fps: u32, } impl CapPortal { @@ -209,7 +212,6 @@ impl CapPortal { shutdown_read: unsafe { OwnedFd::from_raw_fd(efd) }, pw_fd, node_id, - fps: args.fps, }; let pw_thread = thread::Builder::new() @@ -697,7 +699,6 @@ fn pipewire_thread(ctx: PwThreadCtx) { shutdown_read, pw_fd, node_id, - fps: _, } = ctx; let mainloop = match pw::main_loop::MainLoopBox::new(None) { @@ -1070,15 +1071,6 @@ fn pipewire_thread(ctx: PwThreadCtx) { // PipeWire global state is intentionally not deinitialized here — see pw::init() comment above. } -/// 将四个 ASCII 字符编码为 32 位 FourCC (Four Character Code) 标识符 -/// -/// FourCC 是多媒体领域中广泛使用的像素格式标识方式。 -/// 编码规则: 第一个字符在最低 8 位,依次向高位排列。 -/// 例如: "BGRA" → 0x41524742 (小端序存储为 'B','G','R','A') -const fn fourcc(a: u8, b: u8, c: u8, d: u8) -> u32 { - (a as u32) | ((b as u32) << 8) | ((c as u32) << 16) | ((d as u32) << 24) -} - /// 将 PipeWire SPA 视频格式转换为 DRM FourCC 格式 /// /// PipeWire 使用自己的 VideoFormat 枚举,而 DRM/KMS 使用 FourCC 格式标识。 diff --git a/src/state.rs b/src/state.rs index fc00bf6..47c9343 100644 --- a/src/state.rs +++ b/src/state.rs @@ -77,8 +77,6 @@ pub trait CaptureSource: Sized + 'static { pub struct OutputInfo { pub name: String, pub transform: Transform, - pub physical_size: (i32, i32), - pub logical_position: (i32, i32), } #[derive(Default)] @@ -174,7 +172,6 @@ pub(crate) enum EncConstructionStage { dmabuf: ZwpLinuxDmabufV1, }, Streaming { - output_info: OutputInfo, output: WlOutput, enc: StreamingEncoder, cap: S, @@ -209,7 +206,6 @@ pub enum InFlightSurface { pub struct State { pub(crate) stage: EncConstructionStage, pub in_flight_surface: InFlightSurface, - pub starting_timestamp: Option, pub stats_start_time: Option, pub stats_last_time: Option, pub stats_frames: u64, @@ -302,7 +298,6 @@ impl State { wlr_head_proxy_to_name: HashMap::new(), }, in_flight_surface: InFlightSurface::None, - starting_timestamp: None, stats_start_time: None, stats_last_time: None, stats_frames: 0, @@ -479,7 +474,6 @@ impl State { pub fn on_frame_allocd(&mut self, frame: S::Frame, format: u32, width: u32, height: u32) { let (frames_rgb_ctx, dmabuf, cap) = match &mut self.stage { EncConstructionStage::Streaming { - output_info: _, output: _, enc, dmabuf, @@ -829,7 +823,6 @@ impl State { bitrate ); self.stage = EncConstructionStage::Streaming { - output_info, output, enc, cap, @@ -985,8 +978,6 @@ impl State { .or(info.wl_name.clone()) .unwrap_or_else(|| format!("output-{}", output_names[target_idx])), transform: info.transform.unwrap(), - physical_size: info.physical_size.unwrap(), - logical_position: info.logical_position.unwrap_or((0, 0)), }; let output = bound_outputs[target_idx].clone(); diff --git a/src/state_portal.rs b/src/state_portal.rs index 9c6f1ec..4ebb387 100644 --- a/src/state_portal.rs +++ b/src/state_portal.rs @@ -2,6 +2,7 @@ // AsRawFd is required by frame.fd.as_raw_fd() in build_drm_descriptor below // but rustc emits a false "unused_imports" warning because OwnedFd also has // an inherent as_raw_fd — same quirk as avhw.rs. E0599 if removed → keep it. +#[allow(unused_imports)] use std::os::fd::AsRawFd; use std::path::PathBuf; use std::sync::atomic::{AtomicBool, Ordering};