get the encoder work off the main thread and harden the update path
This commit is contained in:
+15
-7
@@ -369,6 +369,10 @@ fn clear_temp_segments(app_dir: &Path, keep_previews: bool) {
|
||||
if (name.starts_with("segment-") && has_ext(name, "mp4"))
|
||||
|| (name.starts_with("audio-") && has_ext(name, "pcm"))
|
||||
|| (name.starts_with("preview-palette-") && has_ext(name, "png"))
|
||||
// Two-pass stats, named ffmpeg2pass-0.log and its .mbtree
|
||||
// sibling. cleanup_pass_logs only runs on a successful
|
||||
// encode, so a cancelled one left them here forever.
|
||||
|| name.starts_with("ffmpeg2pass")
|
||||
|| padtmp
|
||||
{
|
||||
drop(std::fs::remove_file(entry.path()));
|
||||
@@ -622,7 +626,7 @@ fn start_capture(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
#[tauri::command(async)]
|
||||
fn pause_capture(state: State<'_, AppState>) -> Result<(), String> {
|
||||
let session = lock(&state.capture)
|
||||
.take()
|
||||
@@ -760,7 +764,7 @@ fn restart_audio_capture(
|
||||
clippy::too_many_lines,
|
||||
reason = "one recording-finalisation transaction; the steps share session state and temp paths"
|
||||
)]
|
||||
#[tauri::command]
|
||||
#[tauri::command(async)]
|
||||
fn stop_capture(state: State<'_, AppState>) -> Result<RecordedClip, String> {
|
||||
let mut ss = lock(&state.session)
|
||||
.take()
|
||||
@@ -955,7 +959,7 @@ pub struct PreviewRequest {
|
||||
pub duration_secs: Option<f64>,
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
#[tauri::command(async)]
|
||||
fn render_preview(
|
||||
state: State<'_, AppState>,
|
||||
request: PreviewRequest,
|
||||
@@ -1138,6 +1142,8 @@ mod tests {
|
||||
"audio-001.pcm",
|
||||
"preview.png",
|
||||
"raw-preview.png",
|
||||
"ffmpeg2pass-0.log",
|
||||
"ffmpeg2pass-0.log.mbtree",
|
||||
] {
|
||||
std::fs::write(temp.join(name), b"x").unwrap();
|
||||
}
|
||||
@@ -1147,6 +1153,8 @@ mod tests {
|
||||
assert!(!temp.join("audio-concat.pcm.padtmp").exists(), "padtmp should be swept");
|
||||
assert!(!temp.join("segment-001.mp4").exists());
|
||||
assert!(!temp.join("audio-001.pcm").exists());
|
||||
assert!(!temp.join("ffmpeg2pass-0.log").exists(), "pass stats should be swept");
|
||||
assert!(!temp.join("ffmpeg2pass-0.log.mbtree").exists());
|
||||
assert!(temp.join("preview.png").exists(), "preview must survive a new capture");
|
||||
assert!(temp.join("raw-preview.png").exists());
|
||||
|
||||
@@ -1192,7 +1200,7 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
#[tauri::command(async)]
|
||||
fn extract_thumbnails(
|
||||
state: State<'_, AppState>,
|
||||
fps: u32,
|
||||
@@ -1209,7 +1217,7 @@ fn extract_thumbnails(
|
||||
.map_err(|e| format!("{e:#}"))
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
#[tauri::command(async)]
|
||||
fn render_raw_preview(
|
||||
state: State<'_, AppState>,
|
||||
timestamp: f64,
|
||||
@@ -1889,7 +1897,7 @@ fn read_log_tail(log_dir: &Path) -> String {
|
||||
String::from_utf8_lossy(data.get(start..).unwrap_or_default()).into_owned()
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
#[tauri::command(async)]
|
||||
fn diagnostics_info(state: State<'_, AppState>) -> DiagnosticsInfo {
|
||||
let log_dir = state.app_dir.join("logs");
|
||||
let log_tail = read_log_tail(&log_dir);
|
||||
@@ -1936,7 +1944,7 @@ fn cancel_export(state: State<'_, AppState>) {
|
||||
state.export_cancel.store(true, Ordering::SeqCst);
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
#[tauri::command(async)]
|
||||
/// Tauri deserializes the return into a JS Result, so the wrapper stays even
|
||||
/// though there is no failure path.
|
||||
#[allow(
|
||||
|
||||
Reference in New Issue
Block a user