Capture-ring FLAC recording¶
FlacRecorder validates matching ring channels and 1..65536 worker scratch frames
before creating an incremental writer. The caller supplies the empty sink, format,
total frame/byte budgets, prepared audio consumer and FlacCapturePolicy.
RejectOverload rejects finite values outside -1..1; ClipOverload explicitly
clips them. Both reject NaN/infinity. PCM16/24 quantization rounds nearest with
ties away from zero, maps -1/+1 to signed minimum/maximum and adds no dither or
level scaling. Channel order and configured file rate stay caller policy.
pump drains at most its prepared batch, validates the whole dequeued input,
then quantizes/encodes/writes on the worker. Empty pumps perform no file I/O.
Any failure after dequeue poisons the recorder: dequeued samples cannot roll back,
and writer failure can leave an accepted/output prefix. frames reports encoder
accepted frames, including pending data; rejected batches are excluded. Audio
producer publication remains prepared and heap-free; ring backpressure/drops are
explicit producer policy. Worker scratch is bounded, while encoder working
allocations/time remain backend policy.
Stop/join the producer before finish, which drains at most one ring capacity
and finalizes the nonempty file. Drop never finalizes. Continued late publication
can reject or lose late data; no hidden scheduler or clock conversion is added.
cargo run -p ravet-audio-file --features flac-encode --example capture-flac --locked -- target/flac-capture
This creates a new directory with two public synthetic stereo PCM16/24 records and actual threaded capture-to-FLAC files. Independent FFmpeg checks reproduce both 8193-frame records byte for byte. Four acceptance groups cover endpoints/ ties/overload policy, stopped tail draining, malformed/capacity and partial output poison, and exact threaded order with measured heap-free producer handoff. This is synthetic capture, with no physical device/real-time deadline claim. See decision 0075.