Phase 6: Add WAV clips, graph playback and bounded recording
This commit is contained in:
parent
65640c4aad
commit
8a37090b81
40 changed files with 1450 additions and 69 deletions
|
|
@ -1,3 +1,4 @@
|
|||
#define _POSIX_C_SOURCE 200809L
|
||||
/* JACK ABI fake: deterministic fault injection, linked without libjack.
|
||||
* Processing is driven synchronously here; realtime concurrency is tested
|
||||
* separately by test_realtime. No fake header replaces installed declarations. */
|
||||
|
|
@ -7,6 +8,7 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#define CHECK(c) do { if (!(c)) { fprintf(stderr,"FAIL %s:%d: %s\n",__FILE__,__LINE__,#c); return 1; } } while (0)
|
||||
static JackProcessCallback process_cb;
|
||||
static JackSampleRateCallback rate_cb;
|
||||
|
|
@ -182,6 +184,58 @@ int main(void)
|
|||
close_fail = 0;
|
||||
CHECK(xtc_backend_close(backend) == XTC_OK);
|
||||
}
|
||||
{
|
||||
char directory[] = "/tmp/xtc-backend-audio-XXXXXX", take[256], song[256];
|
||||
xtc_project *p = NULL, *q = NULL;
|
||||
xtc_recorder *recorder = NULL;
|
||||
uint64_t track, clip, captured;
|
||||
CHECK(mkdtemp(directory) != NULL);
|
||||
snprintf(take, sizeof(take), "%s/take.wav", directory);
|
||||
snprintf(song, sizeof(song), "%s/song.xtc", directory);
|
||||
CHECK(xtc_project_create(&p) == XTC_OK && xtc_project_create(&q) == XTC_OK);
|
||||
CHECK(xtc_project_add_track(p, "Take", &track) == XTC_OK);
|
||||
CHECK(xtc_backend_open(&config, &backend) == XTC_OK);
|
||||
CHECK(xtc_backend_prepare_project(backend, p) == XTC_OK);
|
||||
CHECK(xtc_recorder_create(take, 48000, 256, &recorder) == XTC_OK);
|
||||
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_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);
|
||||
deactivate_fail = 1;
|
||||
CHECK(xtc_backend_stop(backend) == XTC_ERR_IO);
|
||||
CHECK(process_cb(32, context) == 0);
|
||||
deactivate_fail = 0;
|
||||
CHECK(xtc_backend_stop(backend) == XTC_OK);
|
||||
CHECK(xtc_backend_set_recorder(backend, NULL) == XTC_OK);
|
||||
CHECK(xtc_recorder_finish(recorder) == XTC_OK);
|
||||
CHECK(xtc_recorder_status(recorder, &captured) == XTC_OK && captured == 64);
|
||||
xtc_recorder_destroy(recorder);
|
||||
CHECK(xtc_recorder_create(take, 48000, 256, &recorder) == XTC_OK);
|
||||
CHECK(xtc_backend_set_recorder(backend, recorder) == XTC_OK && xtc_backend_start(backend) == XTC_OK);
|
||||
null_buffer = 1; CHECK(process_cb(32, context) == 0); null_buffer = 0;
|
||||
CHECK(process_cb(32, context) == 0); /* Never silently resume after missing callback data. */
|
||||
CHECK(xtc_recorder_status(recorder, &captured) == XTC_ERR_IO && captured == 0);
|
||||
CHECK(xtc_backend_stop(backend) == XTC_OK && xtc_backend_set_recorder(backend, NULL) == XTC_OK);
|
||||
CHECK(xtc_recorder_finish(recorder) == XTC_ERR_IO);
|
||||
xtc_recorder_destroy(recorder); /* Prior destination take must survive. */
|
||||
CHECK(xtc_project_import_audio(p, track, take, 0, &clip) == XTC_OK);
|
||||
CHECK(xtc_project_save(p, song) == XTC_OK && xtc_project_load(q, song) == XTC_OK);
|
||||
CHECK(xtc_backend_prepare_project(backend, q) == XTC_OK);
|
||||
CHECK(xtc_backend_seek(backend, 0) == XTC_OK && xtc_backend_start(backend) == XTC_OK);
|
||||
CHECK(unlink(take) == 0); /* Immutable plan is already loaded. */
|
||||
CHECK(process_cb(32, context) == 0 && memcmp(input, output, 32 * sizeof(float)) == 0);
|
||||
CHECK(xtc_backend_stop(backend) == XTC_OK);
|
||||
CHECK(xtc_backend_prepare_project(backend, q) == XTC_OK);
|
||||
CHECK(xtc_backend_get_status(backend, &status) == XTC_OK && status.asset_issues == 1);
|
||||
CHECK(strcmp(xtc_backend_asset_issue(backend), take) == 0);
|
||||
CHECK(xtc_backend_seek(backend, 0) == XTC_OK && xtc_backend_start(backend) == XTC_OK);
|
||||
CHECK(process_cb(32, context) == 0 && output[0] == 0.0f);
|
||||
CHECK(xtc_backend_close(backend) == XTC_OK);
|
||||
xtc_project_destroy(p); xtc_project_destroy(q);
|
||||
CHECK(unlink(song) == 0 && rmdir(directory) == 0);
|
||||
}
|
||||
CHECK(closed >= 104);
|
||||
CHECK(xtc_backend_close(NULL) == XTC_OK);
|
||||
xtc_graph_destroy(invalid_graph);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue