mirror of
https://github.com/storytold/soundcraft.git
synced 2026-11-02 06:56:53 -06:00
Record to disk: keep a partial frame between pops so channels never shift
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
cfe6b42d00
commit
d87d0373ee
@@ -179,9 +179,12 @@ fn write_takes(shared: &Shared, mut takes: Vec<TakeWriter>, channels: usize) ->
|
||||
let (mut block, mut header_written) = (Vec::new(), Instant::now());
|
||||
loop {
|
||||
let stopping = !shared.armed.load(Ordering::Acquire);
|
||||
block.clear();
|
||||
// The ring holds interleaved samples and a pop can end mid-frame: write whole frames and
|
||||
// keep the remainder for the next pop, so channels never shift.
|
||||
shared.ring.pop_all(&mut block);
|
||||
takes.iter_mut().for_each(|t| t.write(&block, channels));
|
||||
let whole = block.len() - block.len() % channels.max(1);
|
||||
takes.iter_mut().for_each(|t| t.write(&block[..whole], channels));
|
||||
block.drain(..whole);
|
||||
if stopping {
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user