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))
|
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(
|
pub(crate) fn start(
|
||||||
output_path: PathBuf,
|
output_path: PathBuf,
|
||||||
ffmpeg_path: PathBuf,
|
ffmpeg_path: PathBuf,
|
||||||
@@ -693,6 +697,10 @@ impl CaptureSession {
|
|||||||
/// Idempotent: if `input` has already been consumed (e.g. a previous
|
/// Idempotent: if `input` has already been consumed (e.g. a previous
|
||||||
/// pause/resume cycle ran this to completion and removed it), and
|
/// pause/resume cycle ran this to completion and removed it), and
|
||||||
/// `output` exists, returns Ok without re-running ffmpeg.
|
/// `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(
|
pub(crate) fn fix_intermediate_fps(
|
||||||
ffmpeg: &std::path::Path,
|
ffmpeg: &std::path::Path,
|
||||||
input: &std::path::Path,
|
input: &std::path::Path,
|
||||||
|
|||||||
+13
-11
@@ -774,11 +774,13 @@ fn stop_capture(app: AppHandle, state: State<'_, AppState>) -> Result<RecordedCl
|
|||||||
vc
|
vc
|
||||||
};
|
};
|
||||||
|
|
||||||
let have_audio = !ss.audio_segments.is_empty()
|
// Bind the audio format here instead of unwrapping at each use below; the
|
||||||
&& ss.audio_sample_rate.is_some()
|
// if-let is the same condition previous `is_some()` checks encoded.
|
||||||
&& ss.audio_channels.is_some();
|
if let (false, Some(sample_rate), Some(channels)) = (
|
||||||
|
ss.audio_segments.is_empty(),
|
||||||
if have_audio {
|
ss.audio_sample_rate,
|
||||||
|
ss.audio_channels,
|
||||||
|
) {
|
||||||
if !ffmpeg.is_file() {
|
if !ffmpeg.is_file() {
|
||||||
return Err("ffmpeg.exe not found for audio mux".to_string());
|
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 {
|
if head_offset_secs > 0.001 {
|
||||||
pad_audio_head(
|
pad_audio_head(
|
||||||
&audio_concat,
|
&audio_concat,
|
||||||
ss.audio_sample_rate.unwrap(),
|
sample_rate,
|
||||||
ss.audio_channels.unwrap(),
|
channels,
|
||||||
head_offset_secs,
|
head_offset_secs,
|
||||||
)
|
)
|
||||||
.map_err(|e| format!("padding audio head: {e:#}"))?;
|
.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(
|
adjust_audio_length(
|
||||||
&audio_concat,
|
&audio_concat,
|
||||||
ss.audio_sample_rate.unwrap(),
|
sample_rate,
|
||||||
ss.audio_channels.unwrap(),
|
channels,
|
||||||
ss.total_recorded_secs,
|
ss.total_recorded_secs,
|
||||||
)
|
)
|
||||||
.map_err(|e| format!("adjusting audio length: {e:#}"))?;
|
.map_err(|e| format!("adjusting audio length: {e:#}"))?;
|
||||||
@@ -813,8 +815,8 @@ fn stop_capture(app: AppHandle, state: State<'_, AppState>) -> Result<RecordedCl
|
|||||||
&ffmpeg,
|
&ffmpeg,
|
||||||
&video_concat,
|
&video_concat,
|
||||||
&audio_concat,
|
&audio_concat,
|
||||||
ss.audio_sample_rate.unwrap(),
|
sample_rate,
|
||||||
ss.audio_channels.unwrap(),
|
channels,
|
||||||
&final_path,
|
&final_path,
|
||||||
)
|
)
|
||||||
.map_err(|e| format!("mux: {e:#}"))?;
|
.map_err(|e| format!("mux: {e:#}"))?;
|
||||||
|
|||||||
Reference in New Issue
Block a user