tidy bindings, closures and string building
This commit is contained in:
@@ -391,7 +391,8 @@ fn adjust_audio_length(path: &Path, sample_rate: u32, channels: u16, target_secs
|
||||
let to_write = usize::try_from(remaining.min(chunk))
|
||||
.unwrap_or(zeros.len())
|
||||
.min(zeros.len());
|
||||
file.write_all(&zeros[..to_write])?;
|
||||
// to_write was clamped to zeros.len() just above.
|
||||
file.write_all(zeros.get(..to_write).unwrap_or_default())?;
|
||||
remaining -= u64::try_from(to_write).unwrap_or(0);
|
||||
}
|
||||
} else {
|
||||
@@ -428,7 +429,8 @@ fn pad_audio_head(path: &Path, sample_rate: u32, channels: u16, head_secs: f64)
|
||||
let to_write = usize::try_from(remaining.min(chunk))
|
||||
.unwrap_or(zeros.len())
|
||||
.min(zeros.len());
|
||||
out.write_all(&zeros[..to_write])?;
|
||||
// to_write was clamped to zeros.len() just above.
|
||||
out.write_all(zeros.get(..to_write).unwrap_or_default())?;
|
||||
remaining -= u64::try_from(to_write).unwrap_or(0);
|
||||
}
|
||||
out.flush()?;
|
||||
@@ -617,7 +619,7 @@ fn pause_capture(state: State<'_, AppState>) -> Result<(), String> {
|
||||
.map_err(|e| format!("fixing fps: {e:#}"))?;
|
||||
let path = if fixed_path.exists() { fixed_path } else { raw_path };
|
||||
|
||||
let audio_path = lock(&state.audio).take().map(|a| a.stop());
|
||||
let audio_path = lock(&state.audio).take().map(audio::AudioSession::stop);
|
||||
|
||||
let new_clicks: Vec<clicks::Click> = lock(&state.click_recorder)
|
||||
.take()
|
||||
@@ -2197,12 +2199,12 @@ pub fn run() {
|
||||
])
|
||||
.build(tauri::generate_context!())
|
||||
.expect("error while building ByteSize");
|
||||
app.run(|_app: &AppHandle, event| {
|
||||
app.run(|app, event| {
|
||||
if let tauri::RunEvent::Exit = event {
|
||||
if let Some(st) = _app.try_state::<AppState>() {
|
||||
if let Some(st) = app.try_state::<AppState>() {
|
||||
st.overlay_poll_shutdown.store(true, Ordering::SeqCst);
|
||||
}
|
||||
cleanup_temp_on_exit(_app);
|
||||
cleanup_temp_on_exit(app);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user