Phase 12: Improve audio transitions and verify sample-accurate timing

This commit is contained in:
Johannes Findeisen 2026-10-27 03:37:19 +01:00
commit 05140c2e93
29 changed files with 795 additions and 33 deletions

View file

@ -216,6 +216,7 @@ int main(void)
CHECK(xtc_backend_set_recorder(backend, recorder) == XTC_OK);
CHECK(xtc_backend_start(backend) == XTC_OK);
CHECK(xtc_backend_set_recorder(backend, NULL) == XTC_ERR_INVALID_STATE);
CHECK(xtc_backend_request_stop(backend) == XTC_ERR_INVALID_STATE);
CHECK(xtc_backend_prepare_project(backend, p) == XTC_ERR_INVALID_STATE);
for (i = 0; i < 32; ++i) input[i] = i % 2 ? -0.5f : 0.25f;
CHECK(process_cb(32, context) == 0);
@ -318,6 +319,39 @@ int main(void)
CHECK(xtc_backend_get_status(backend, &status) == XTC_OK && status.peak_right == 0);
CHECK(xtc_backend_close(backend) == XTC_OK); xtc_project_destroy(p);
}
{
uint64_t held;
config.channel_count = 2;
CHECK(xtc_backend_open(&config, &backend) == XTC_OK);
CHECK(xtc_backend_set_transition_frames(backend, 65537) == XTC_ERR_INVALID_ARGUMENT);
CHECK(xtc_backend_set_transition_frames(backend, 4) == XTC_OK);
CHECK(xtc_backend_submit(backend, graph) == XTC_OK);
for (i = 0; i < 128; ++i) input[i] = 1;
CHECK(xtc_backend_start(backend) == XTC_OK);
CHECK(xtc_backend_set_transition_frames(backend, 4) == XTC_ERR_INVALID_STATE);
CHECK(process_cb(4, context) == 0);
CHECK(output[0] == 0.125f && output[3] == 0.5f && output_right[3] == output[3]);
CHECK(xtc_backend_request_stop(backend) == XTC_OK);
CHECK(process_cb(2, context) == 0 && output[0] == 0.375f && output[1] == 0.25f);
CHECK(xtc_backend_request_stop(backend) == XTC_OK); /* Must not restart ramp. */
CHECK(process_cb(2, context) == 0 && output[0] == 0.125f && output[1] == 0);
CHECK(xtc_backend_get_status(backend, &status) == XTC_OK && status.running && status.stopping);
held = status.sample_position;
CHECK(process_cb(32, context) == 0 && output[0] == 0 && output[31] == 0);
CHECK(xtc_backend_get_status(backend, &status) == XTC_OK && status.sample_position == held);
deactivate_fail = 1;
xtc_backend_collect(backend);
CHECK(xtc_backend_get_status(backend, &status) == XTC_OK && status.running && status.process_result == XTC_ERR_IO);
deactivate_fail = 0;
xtc_backend_collect(backend);
CHECK(xtc_backend_get_status(backend, &status) == XTC_OK && !status.running && !status.stopping);
CHECK(xtc_backend_start(backend) == XTC_OK && process_cb(4, context) == 0 && output[3] == 0.5f);
CHECK(xtc_backend_stop(backend) == XTC_OK); /* Immediate escape stays available. */
CHECK(xtc_backend_set_transition_frames(backend, 0) == XTC_OK);
CHECK(xtc_backend_start(backend) == XTC_OK && xtc_backend_request_stop(backend) == XTC_OK);
CHECK(xtc_backend_get_status(backend, &status) == XTC_OK && !status.running);
CHECK(xtc_backend_close(backend) == XTC_OK);
}
CHECK(closed >= 104);
CHECK(xtc_backend_close(NULL) == XTC_OK);
xtc_graph_destroy(invalid_graph);