Phase 27: strengthen undo transactions and improve editor workflow

This commit is contained in:
Johannes Findeisen 2026-10-27 16:49:30 +01:00
commit c4daef7c42
21 changed files with 460 additions and 27 deletions

View file

@ -2,6 +2,7 @@
* reject host allocation/reclamation inside processing. No production hooks. */
#include "xtc/xtc_realtime.h"
#include "xtc/xtc_native.h"
#include "xtc/xtc_control.h"
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
@ -83,9 +84,53 @@ static void graph_limits(void)
xtc_plan_destroy(plan);
}
static void history_reservations(void)
{
xtc_project *project = NULL, *snapshot = NULL;
xtc_history *history = NULL;
uint64_t track, bus;
unsigned int map[3] = {1,74,11}, actual[3];
size_t undo_count, redo_count, tracks, clips;
int failure, succeeded = 0;
assert(xtc_project_create(&project) == XTC_OK);
assert(xtc_project_add_track(project,"History",&track) == XTC_OK);
assert(xtc_history_create(project,&history) == XTC_OK);
assert(xtc_project_set_mix(project,track,.5f,0,0,0) == XTC_OK);
assert(xtc_history_record(history,project) == XTC_OK);
assert(xtc_history_checkout(history,0,&snapshot) == XTC_OK && xtc_history_accept(history,0) == XTC_OK);
xtc_project_destroy(project); project = snapshot; snapshot = NULL;
for (failure = 0; failure < 12; ++failure) {
xtc_result r;
fail_after = failure;
r = xtc_history_reserve(history);
fail_after = -1;
assert(xtc_history_counts(history,&undo_count,&redo_count) == XTC_OK && undo_count == 0 && redo_count == 1);
if (r == XTC_OK) { succeeded = 1; break; }
assert(r == XTC_ERR_OUT_OF_MEMORY);
}
assert(succeeded);
fail_after = 0; // Fail every allocation: reserved record must still succeed.
assert(xtc_history_reserve(history) == XTC_OK);
assert(xtc_project_add_bus(project,"Bus",&bus) == XTC_OK);
assert(xtc_project_route_track(project,track,bus) == XTC_OK);
assert(xtc_project_set_control_map(project,0,map) == XTC_OK);
assert(xtc_history_record(history,project) == XTC_OK);
fail_after = -1;
assert(xtc_history_counts(history,&undo_count,&redo_count) == XTC_OK && undo_count == 1 && redo_count == 0);
assert(xtc_history_checkout(history,0,&snapshot) == XTC_OK);
assert(xtc_project_get_counts(snapshot,&tracks,&clips) == XTC_OK && tracks == 1 && clips == 0);
assert(xtc_project_get_control_map(snapshot,0,actual) == XTC_OK && actual[0] == 7);
xtc_project_destroy(snapshot); snapshot = NULL;
assert(xtc_history_accept(history,0) == XTC_OK && xtc_history_checkout(history,1,&snapshot) == XTC_OK);
assert(xtc_project_get_counts(snapshot,&tracks,&clips) == XTC_OK && tracks == 2);
assert(xtc_project_get_control_map(snapshot,0,actual) == XTC_OK && actual[0] == 1 && actual[1] == 74);
xtc_project_destroy(snapshot); xtc_project_destroy(project); xtc_history_destroy(history);
}
int main(void)
{
graph_limits();
history_reservations();
xtc_native_descriptor descriptor = {XTC_NATIVE_ABI_VERSION, sizeof(descriptor),
"reliability.gain", XTC_NATIVE_EFFECT, prepare, reset, process, destroy};
xtc_graph *graph = NULL;