Phase 13: protect recordings and recover retained audio after write failures
This commit is contained in:
parent
05140c2e93
commit
01d9db90fd
15 changed files with 308 additions and 30 deletions
|
|
@ -90,7 +90,7 @@ int main(void)
|
|||
}
|
||||
/* Recording ring wraps, exact samples survive WAV -> project -> reopen. */
|
||||
for (i = 0; i < 64; ++i) input[i] = i % 2 ? -0.5f : 0.25f;
|
||||
assert(xtc_recorder_create(take, 48000, 128, &rec) == XTC_OK);
|
||||
assert(xtc_recorder_create_replace(take, 48000, 128, 1, &rec) == XTC_OK);
|
||||
for (i = 0; i < 10; ++i) {
|
||||
xtc_recorder_push(rec, input, 64);
|
||||
assert(xtc_recorder_drain(rec) == XTC_OK);
|
||||
|
|
@ -137,18 +137,18 @@ int main(void)
|
|||
}
|
||||
xtc_project_destroy(p); xtc_project_destroy(q);
|
||||
/* Overflow is sticky, partial file recoverable, destination unchanged until finish. */
|
||||
assert(xtc_recorder_create(take, 48000, 64, &rec) == XTC_OK);
|
||||
assert(xtc_recorder_create_replace(take, 48000, 64, 1, &rec) == XTC_OK);
|
||||
xtc_recorder_push(rec, input, 64); xtc_recorder_push(rec, input, 1);
|
||||
assert(xtc_recorder_status(rec, &frames) == XTC_ERR_CAPACITY && frames == 64);
|
||||
assert(xtc_recorder_finish(rec) == XTC_ERR_CAPACITY); xtc_recorder_destroy(rec);
|
||||
assert(xtc_recorder_create(take, 48000, 64, &rec) == XTC_OK);
|
||||
assert(xtc_recorder_create_replace(take, 48000, 64, 1, &rec) == XTC_OK);
|
||||
xtc_recorder_push(rec, NULL, 1);
|
||||
assert(xtc_recorder_status(rec, &frames) == XTC_ERR_IO);
|
||||
xtc_recorder_destroy(rec);
|
||||
/* Actual concurrent producer/control consumer; no GUI or JACK required. */
|
||||
{
|
||||
stress s = {0}; pthread_t thread;
|
||||
assert(xtc_recorder_create(take, 48000, 524288, &rec) == XTC_OK); s.r = rec;
|
||||
assert(xtc_recorder_create_replace(take, 48000, 524288, 1, &rec) == XTC_OK); s.r = rec;
|
||||
assert(pthread_create(&thread, NULL, producer, &s) == 0);
|
||||
while (!__atomic_load_n(&s.complete, __ATOMIC_ACQUIRE)) assert(xtc_recorder_drain(rec) == XTC_OK);
|
||||
assert(pthread_join(thread, NULL) == 0);
|
||||
|
|
|
|||
|
|
@ -212,7 +212,7 @@ int main(void)
|
|||
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_recorder_create_replace(take, 48000, 256, 1, &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);
|
||||
|
|
@ -229,7 +229,7 @@ int main(void)
|
|||
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_recorder_create_replace(take, 48000, 256, 1, &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. */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue