replace production unwraps with real handling
This commit is contained in:
@@ -566,6 +566,10 @@ fn monitor_at_point(x: i32, y: i32) -> Result<Monitor> {
|
||||
Ok(Monitor::from_raw_hmonitor(hmonitor.0))
|
||||
}
|
||||
|
||||
#[allow(
|
||||
clippy::expect_used,
|
||||
reason = "Windows always has a primary monitor; if enumeration fails there is nothing sensible to capture instead"
|
||||
)]
|
||||
pub(crate) fn start(
|
||||
output_path: PathBuf,
|
||||
ffmpeg_path: PathBuf,
|
||||
@@ -693,6 +697,10 @@ impl CaptureSession {
|
||||
/// Idempotent: if `input` has already been consumed (e.g. a previous
|
||||
/// pause/resume cycle ran this to completion and removed it), and
|
||||
/// `output` exists, returns Ok without re-running ffmpeg.
|
||||
#[allow(
|
||||
clippy::expect_used,
|
||||
reason = "callers rule out the None case that capture_timing returns None for"
|
||||
)]
|
||||
pub(crate) fn fix_intermediate_fps(
|
||||
ffmpeg: &std::path::Path,
|
||||
input: &std::path::Path,
|
||||
|
||||
+13
-11
@@ -774,11 +774,13 @@ fn stop_capture(app: AppHandle, state: State<'_, AppState>) -> Result<RecordedCl
|
||||
vc
|
||||
};
|
||||
|
||||
let have_audio = !ss.audio_segments.is_empty()
|
||||
&& ss.audio_sample_rate.is_some()
|
||||
&& ss.audio_channels.is_some();
|
||||
|
||||
if have_audio {
|
||||
// Bind the audio format here instead of unwrapping at each use below; the
|
||||
// if-let is the same condition previous `is_some()` checks encoded.
|
||||
if let (false, Some(sample_rate), Some(channels)) = (
|
||||
ss.audio_segments.is_empty(),
|
||||
ss.audio_sample_rate,
|
||||
ss.audio_channels,
|
||||
) {
|
||||
if !ffmpeg.is_file() {
|
||||
return Err("ffmpeg.exe not found for audio mux".to_string());
|
||||
}
|
||||
@@ -794,8 +796,8 @@ fn stop_capture(app: AppHandle, state: State<'_, AppState>) -> Result<RecordedCl
|
||||
if head_offset_secs > 0.001 {
|
||||
pad_audio_head(
|
||||
&audio_concat,
|
||||
ss.audio_sample_rate.unwrap(),
|
||||
ss.audio_channels.unwrap(),
|
||||
sample_rate,
|
||||
channels,
|
||||
head_offset_secs,
|
||||
)
|
||||
.map_err(|e| format!("padding audio head: {e:#}"))?;
|
||||
@@ -804,8 +806,8 @@ fn stop_capture(app: AppHandle, state: State<'_, AppState>) -> Result<RecordedCl
|
||||
}
|
||||
adjust_audio_length(
|
||||
&audio_concat,
|
||||
ss.audio_sample_rate.unwrap(),
|
||||
ss.audio_channels.unwrap(),
|
||||
sample_rate,
|
||||
channels,
|
||||
ss.total_recorded_secs,
|
||||
)
|
||||
.map_err(|e| format!("adjusting audio length: {e:#}"))?;
|
||||
@@ -813,8 +815,8 @@ fn stop_capture(app: AppHandle, state: State<'_, AppState>) -> Result<RecordedCl
|
||||
&ffmpeg,
|
||||
&video_concat,
|
||||
&audio_concat,
|
||||
ss.audio_sample_rate.unwrap(),
|
||||
ss.audio_channels.unwrap(),
|
||||
sample_rate,
|
||||
channels,
|
||||
&final_path,
|
||||
)
|
||||
.map_err(|e| format!("mux: {e:#}"))?;
|
||||
|
||||
Reference in New Issue
Block a user