Phase 13: protect recordings and recover retained audio after write failures

This commit is contained in:
Johannes Findeisen 2026-10-27 03:46:09 +01:00
commit 01d9db90fd
15 changed files with 308 additions and 30 deletions

View file

@ -95,7 +95,7 @@ xtc_result xtc_audio_plan_render(const xtc_audio_plan *plan, uint64_t position,
* Ring capacity 1..2097152 frames. One callback producer, one control consumer.
* push accepts whole blocks; overflow is sticky and all later input is dropped.
* drain performs file I/O; call regularly. finish requires producer quiescence,
* drains, finalizes and atomically renames even on overflow (partial recovery).
* drains, finalizes and publishes without overwriting even on overflow (partial recovery).
* No source/recorder is freed until destroy, which also removes unfinished temp.
* Counts and sticky error can be observed while producing. */
/**
@ -139,11 +139,23 @@ xtc_result xtc_recorder_finish(xtc_recorder *recorder);
*/
xtc_result xtc_recorder_status(const xtc_recorder *recorder, uint64_t *out_frames);
/**
* @brief Releases recorder storage and removes any unfinished temporary file; accepts NULL.
* @brief Finalizes pending accepted frames after producer quiescence; preserves failed temporaries.
*
* @param recorder Recorder handle.
*/
void xtc_recorder_destroy(xtc_recorder *recorder);
/* Default create refuses any existing destination (including symlinks). Explicit
* replacement retains the old behavior for callers that obtained authorization.
* Final publication is race-safe: no-clobber link, or explicit replace/rename. */
xtc_result xtc_recorder_create_replace(const char *path, unsigned int rate, size_t capacity, int replace,
xtc_recorder **out_recorder);
/* Control-thread borrowed path. After a failed finish, copy before destroy.
* Useful temporary data survives destroy on failed finalization. */
const char *xtc_recorder_recovery_path(const xtc_recorder *recorder);
/* Salvage complete mono float32 frames from xtc's interrupted recording format
* to a NEW destination. Never modifies the source or overwrites an existing file. */
xtc_result xtc_recorder_recover(const char *temporary, const char *destination);
#ifdef __cplusplus
}