replace production unwraps with real handling
This commit is contained in:
+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