fix(state_portal): replace expect() with bail-style error propagation (closes #9)
This commit is contained in:
@@ -164,7 +164,8 @@ impl StatePortal {
|
||||
|
||||
// 根据是否启用 WebRTC 选择不同的编码器构造方式
|
||||
let enc = if let Some(ref tx) = self.webrtc_tx {
|
||||
let paused = self.webrtc_paused.as_ref().expect("webrtc_paused must exist when webrtc_tx exists");
|
||||
let paused = self.webrtc_paused.as_ref()
|
||||
.ok_or_else(|| anyhow::anyhow!("internal invariant broken: webrtc_paused missing while WebRTC mode is active"))?;
|
||||
avhw::SwEncState::new_webrtc(
|
||||
&drm_path,
|
||||
frame.width,
|
||||
@@ -179,9 +180,11 @@ impl StatePortal {
|
||||
)?
|
||||
} else {
|
||||
// MP4 模式:编码输出写入文件
|
||||
let output_path = self.args.output.as_deref()
|
||||
.ok_or_else(|| anyhow::anyhow!("--output is required in MP4 file output mode; use --port > 0 for WebRTC mode"))?;
|
||||
avhw::SwEncState::new(
|
||||
&drm_path,
|
||||
std::path::Path::new(self.args.output.as_deref().expect("output required for MP4 mode")),
|
||||
std::path::Path::new(output_path),
|
||||
frame.width,
|
||||
frame.height,
|
||||
enc_width,
|
||||
|
||||
Reference in New Issue
Block a user