Skip to content

The truly free, open-source, local-first, cross-platform CapCut replacement. Scriptable through a JSON-RPC API & MCP.

chore: main is green again - rustfmt, two clippy lints and a constant only Chatterbox uses

Jareere854f821eb57
diff --git a/src/crates/concat-host/src/cards.rs b/src/crates/concat-host/src/cards.rs
index e33b160f..3eceae0b 100644
--- a/src/crates/concat-host/src/cards.rs
+++ b/src/crates/concat-host/src/cards.rs
@@ -513,7 +513,7 @@ mod tests {
#[ignore = "needs a GPU and writes the cards to a folder of your choosing"]
fn draw_every_card() {
let dir = PathBuf::from(std::env::var("CONCAT_CARDS_OUT").expect("CONCAT_CARDS_OUT"));
- let cards = cards(&Catalogue::builtin(), &dir);
+ let cards = cards(Catalogue::builtin(), &dir);
let mut drawn = 0;
draw_all(&dir, &cards, None, |batch, _| drawn += batch.len());
assert_eq!(drawn, cards.len(), "every card is drawn");
diff --git a/src/crates/concat-mobile/src/lib.rs b/src/crates/concat-mobile/src/lib.rs
index 0550d755..977ac8ce 100644
--- a/src/crates/concat-mobile/src/lib.rs
+++ b/src/crates/concat-mobile/src/lib.rs
@@ -352,7 +352,9 @@ impl Engine {
/// "30000/1001" as a fraction, 30/1 for anything unreadable.
fn rate_of(fraction: &str) -> (i64, i64) {
let mut parts = fraction.split('/');
- let num = parts.next().and_then(|part| part.trim().parse::<i64>().ok());
+ let num = parts
+ .next()
+ .and_then(|part| part.trim().parse::<i64>().ok());
let den = parts
.next()
.map_or(Some(1), |part| part.trim().parse::<i64>().ok());
diff --git a/src/crates/concat-mobile/src/render.rs b/src/crates/concat-mobile/src/render.rs
index 5ce2e1a8..e84ae2ad 100644
--- a/src/crates/concat-mobile/src/render.rs
+++ b/src/crates/concat-mobile/src/render.rs
@@ -94,7 +94,13 @@ impl Handle {
}
/// Draws on `window` from now on; see `Engine::attach_surface`.
- pub fn attach(&self, window: u64, width: u32, height: u32, mode: &str) -> Result<String, String> {
+ pub fn attach(
+ &self,
+ window: u64,
+ width: u32,
+ height: u32,
+ mode: &str,
+ ) -> Result<String, String> {
let (reply, answer) = mpsc::channel();
self.send(Msg::Attach {
window,
@@ -176,7 +182,11 @@ fn run(rx: mpsc::Receiver<Msg>, playback: Arc<Playback>, stats: Arc<Mutex<Stats>
let mut window_frames = 0u32;
let mut scrub_total = 0.0f64;
let stat = |with: &dyn Fn(&mut Stats)| {
- with(&mut stats.lock().unwrap_or_else(|poisoned| poisoned.into_inner()));
+ with(
+ &mut stats
+ .lock()
+ .unwrap_or_else(|poisoned| poisoned.into_inner()),
+ );
};
loop {
@@ -210,7 +220,10 @@ fn run(rx: mpsc::Receiver<Msg>, playback: Arc<Playback>, stats: Arc<Mutex<Stats>
old.release_surface();
}
let made = target::Target::attach(window, width, height, &mode);
- let answer = made.as_ref().map(|made| made.describe()).map_err(Clone::clone);
+ let answer = made
+ .as_ref()
+ .map(|made| made.describe())
+ .map_err(Clone::clone);
if let Ok(made) = made {
stat(&|stats| {
*stats = Stats {
@@ -256,7 +269,10 @@ fn run(rx: mpsc::Receiver<Msg>, playback: Arc<Playback>, stats: Arc<Mutex<Stats>
pending = Some((playback.position_now(), Instant::now()));
}
}
- Msg::Playing { on, duration: total } => {
+ Msg::Playing {
+ on,
+ duration: total,
+ } => {
playing = on;
duration = total;
if on {
@@ -467,7 +483,9 @@ struct Out { @builtin(position) position: vec4<f32>, @location(0) uv: vec2<f32>
.map(|target| Target::Gpu(Box::new(target))),
_ => GpuTarget::new(window.clone(), width, height, wgpu::Backends::VULKAN)
.or_else(|error| {
- log::warn!("Vulkan would not draw on the surface ({error}); trying OpenGL ES");
+ log::warn!(
+ "Vulkan would not draw on the surface ({error}); trying OpenGL ES"
+ );
GpuTarget::new(window, width, height, wgpu::Backends::GL)
})
.map(|target| Target::Gpu(Box::new(target))),
@@ -550,7 +568,9 @@ struct Out { @builtin(position) position: vec4<f32>, @location(0) uv: vec2<f32>
// target, the surface dropped first.
let surface = unsafe {
instance.create_surface_unsafe(wgpu::SurfaceTargetUnsafe::RawHandle {
- raw_display_handle: Some(RawDisplayHandle::Android(AndroidDisplayHandle::new())),
+ raw_display_handle: Some(
+ RawDisplayHandle::Android(AndroidDisplayHandle::new()),
+ ),
raw_window_handle: RawWindowHandle::AndroidNdk(AndroidNdkWindowHandle::new(
window.ptr().cast(),
)),
@@ -648,7 +668,11 @@ struct Out { @builtin(position) position: vec4<f32>, @location(0) uv: vec2<f32>
},
fragment: Some(wgpu::FragmentState {
module: &shader,
- entry_point: Some(if format.is_srgb() { "fs_linear" } else { "fs_plain" }),
+ entry_point: Some(if format.is_srgb() {
+ "fs_linear"
+ } else {
+ "fs_plain"
+ }),
compilation_options: Default::default(),
targets: &[Some(wgpu::ColorTargetState {
format,
@@ -698,10 +722,10 @@ struct Out { @builtin(position) position: vec4<f32>, @location(0) uv: vec2<f32>
);
let spec = spec(doc, at, size, moving);
let started = Instant::now();
- let sources = self
- .gpu
- .monitor
- .frame_sources(Arc::clone(&doc.clips), &doc.settings, spec)?;
+ let sources =
+ self.gpu
+ .monitor
+ .frame_sources(Arc::clone(&doc.clips), &doc.settings, spec)?;
let decoded = started.elapsed();
let drawing = Instant::now();
let texture = self.gpu.monitor.texture_of(&sources, spec)?;
@@ -714,7 +738,9 @@ struct Out { @builtin(position) position: vec4<f32>, @location(0) uv: vec2<f32>
}
other => return Err(format!("no surface texture: {other:?}")),
};
- let view = frame.texture.create_view(&wgpu::TextureViewDescriptor::default());
+ let view = frame
+ .texture
+ .create_view(&wgpu::TextureViewDescriptor::default());
let picture = texture.create_view(&wgpu::TextureViewDescriptor::default());
let bind = self
.gpu
@@ -733,12 +759,12 @@ struct Out { @builtin(position) position: vec4<f32>, @location(0) uv: vec2<f32>
},
],
});
- let mut encoder = self
- .gpu
- .device
- .create_command_encoder(&wgpu::CommandEncoderDescriptor {
- label: Some("spike blit"),
- });
+ let mut encoder =
+ self.gpu
+ .device
+ .create_command_encoder(&wgpu::CommandEncoderDescriptor {
+ label: Some("spike blit"),
+ });
{
let mut pass = encoder.begin_render_pass(&wgpu::RenderPassDescriptor {
label: Some("spike blit"),
diff --git a/src/crates/concat-speech/src/transcribe.rs b/src/crates/concat-speech/src/transcribe.rs
index a3ee01d6..b7ffee53 100644
--- a/src/crates/concat-speech/src/transcribe.rs
+++ b/src/crates/concat-speech/src/transcribe.rs
@@ -277,7 +277,7 @@ fn on_speech(start: f64, end: f64, speech: &[(f64, f64)]) -> (f64, f64) {
let Some(&(first, mut last)) = covered.next() else {
return (start, end);
};
- if let Some(&(_, to)) = covered.last() {
+ if let Some(&(_, to)) = covered.next_back() {
last = to;
}
(start.max(first), end.min(last))
@@ -287,8 +287,7 @@ fn on_speech(start: f64, end: f64, speech: &[(f64, f64)]) -> (f64, f64) {
/// transcription models the first time it is wanted.
fn vad_model(dirs: &AppDirs) -> Result<PathBuf, String> {
let path = models_dir(dirs)?.join("ggml-silero-v6.2.0.bin");
- let whole = std::fs::metadata(&path)
- .is_ok_and(|meta| meta.len() == VAD_MODEL.len() as u64);
+ let whole = std::fs::metadata(&path).is_ok_and(|meta| meta.len() == VAD_MODEL.len() as u64);
if !whole {
let part = path.with_extension("part");
std::fs::write(&part, VAD_MODEL)
@@ -680,7 +679,10 @@ mod tests {
)
.expect("transcribes");
for segment in segments {
- println!("{:7.2} {:7.2} {}", segment.start, segment.end, segment.text);
+ println!(
+ "{:7.2} {:7.2} {}",
+ segment.start, segment.end, segment.text
+ );
}
}
diff --git a/src/crates/concat-speech/src/tts.rs b/src/crates/concat-speech/src/tts.rs
index a8494c10..208bb7c4 100644
--- a/src/crates/concat-speech/src/tts.rs
+++ b/src/crates/concat-speech/src/tts.rs
@@ -1068,6 +1068,7 @@ fn recordings_dir(dirs: &AppDirs) -> Result<PathBuf, String> {
/// How far ahead of Chatterbox's last report its next is taken to be: it
/// reports every few tokens, so a short way.
+#[cfg(feature = "chatterbox")]
const CHATTERBOX_STEP: f32 = 0.02;
/// How many sentences `text` appears to have, at least one: the stretches