Q-W3: main.cpp → pointers+entry+dispatch via 4 capture hoists; one pure wav_codec RIFF owner; ICaptureBackend deleted; capture_realtime rename + finalize split; shared stampCaptureSample; makeUniqueTag gains monotonic counter (fixes same-second batch collisions). 60/60 green.

This commit is contained in:
2026-07-29 10:56:11 -04:00
parent d7d7f7e084
commit 09f7173db2
29 changed files with 2972 additions and 2426 deletions
@@ -0,0 +1,42 @@
#pragma once
// capture_realtime_finalize — the FILE-SIDE half of the realtime-record shell
// (Q-W3, T4-08 split riding the Q-9 rename): discovering the file REAPER actually
// recorded, moving it into the bank, the Auto-tail PCM decay-scan trim, and the
// finished-Sample population. The async record LIFECYCLE (state snapshot/restore,
// begin/tick/abort) lives in capture_realtime_shell.cpp; this half talks to
// wav_codec and the filesystem, not to the transport.
//
// REAPER-facing: the .cpp includes reaper_plugin_functions.h WITHOUT
// REAPERAPI_IMPLEMENT (main.cpp owns the API pointers — CLAUDE.md §contract).
// MediaTrack / ReaProject are forward-declared (via capture.h) so this header
// stays SDK-lite.
#include <string>
#include "shell/capture/capture.h" // CaptureRequest / CaptureResult
#include "core/capture/capture_paths.h" // BankPaths
namespace reasampler::capture {
// Discovers the file REAPER actually recorded onto the temp track: the first media
// item's active take's source file, forward-slashed. Empty string if nothing was
// recorded (no item / take / source). Also used by the lifecycle's flush wait
// (size-stable check) before finalize runs.
std::string recordedFilePath(MediaTrack* temp);
// Builds a CaptureResult for a finalized recording: discover the recorded file,
// move it into the bank at `paths`, Auto-trim the tail decay in place when the
// request asks for it, and populate the Sample (pure sampleFromRecordedCapture +
// the shared stampCaptureSample — both project reads pinned to `proj`, the
// record's OWN project). Returns Ok + Sample on success, or a RenderFailed result.
// Does NOT restore any snapshotted state — the caller restores unconditionally
// afterward (finalize + restore are separate steps so a finalize failure still
// restores). `recordWindowEnd` is the recorded window end in project seconds
// (>= request.endSeconds when a tail was recorded) — the untrimmed-length source.
CaptureResult finalizeRecording(ReaProject* proj, MediaTrack* temp,
const CaptureRequest& request,
const BankPaths& paths,
const std::string& uniqueTag,
double recordWindowEnd);
} // namespace reasampler::capture