Fix jitter restart and WAV size overflow

This commit is contained in:
2026-06-16 17:28:41 -04:00
parent 20643a24de
commit 44bad7b70b
3 changed files with 130 additions and 14 deletions
+13 -3
View File
@@ -51,11 +51,21 @@ Proposed future scope:
Reason for not implementing: the current `run_playback` / `run_capture` code does not retain stream node or port ids, and changing `AUTOCONNECT` behavior plus adding manual `pw-link` calls could destabilize the working audio path. That matches the assignment's "bail if risky" instruction.
## Backlog A21/A22 - correctness fixes
- Fixed A21 in `src/core/jitter.rs`: implausibly large sequence discontinuities now reset the per-peer jitter stream instead of being treated as ordinary late packets or packet loss.
- The reset threshold is `500` frames, about 10 seconds at 20 ms/frame. That covers both same-identity sender restart back to sequence 0 and a faulty/malicious jump far ahead that would otherwise force a long PLC run.
- Added jitter regression tests for both far-behind restart and far-ahead jump cases.
- Fixed A22 in `src/audio/recorder.rs`: `WavWriter` now tracks data bytes as `u64`, checks additions before writing, and rejects data that cannot fit both the RIFF size field and the `data` chunk size field.
- Added a WAV overflow regression test that exercises the limit without creating a huge file.
Unverified: the same-identity peer restart has not been exercised in a live 2-machine call; the WAV fix is counter/size-field tested, not a real >12h recording.
## Verification
- `cargo test --lib` passed: 285 passed, 0 failed, 2 ignored.
- `cargo test --lib` passed: 288 passed, 0 failed, 2 ignored.
- `cargo clippy --all-targets` passed.
- `cargo build --release` passed.
- `cargo fmt --check` reports broad repo-wide formatting diffs, including untouched files; I did not run `cargo fmt` to avoid unrelated churn.
- Formatted the touched Rust files with `rustfmt --edition 2024`; I did not run repo-wide `cargo fmt` to avoid unrelated formatting churn.
No new dependencies were added. I did not run git commands.
No new dependencies were added. Runtime/manual/field verification is still pending for audio-device and 2-machine behavior.