diff options
author | David Robillard <d@drobilla.net> | 2024-11-17 20:34:23 -0500 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2024-11-24 19:07:47 -0500 |
commit | 3d28124c93ac8a9e4ad5e244b64cc02daac5e430 (patch) | |
tree | c4bfeff3fbb280486e06e61e52175f9b1e0cc470 /src/jalv.c | |
parent | f80653bc457aef835cd49ad68a5b7fa53db262f9 (diff) | |
download | jalv-3d28124c93ac8a9e4ad5e244b64cc02daac5e430.tar.gz jalv-3d28124c93ac8a9e4ad5e244b64cc02daac5e430.tar.bz2 jalv-3d28124c93ac8a9e4ad5e244b64cc02daac5e430.zip |
Clean up backend allocation and setup
Separate the concerns of backend allocation and initialization, and always
handle allocation at the top level. This avoids multiple confusing paths of
backend allocation and configuration in the internal Jack backend.
Diffstat (limited to 'src/jalv.c')
-rw-r--r-- | src/jalv.c | 15 |
1 files changed, 10 insertions, 5 deletions
@@ -966,7 +966,7 @@ jalv_open(Jalv* const jalv, int* argc, char*** argv) jalv_create_controls(jalv, true); jalv_create_controls(jalv, false); - if (!(jalv->backend = jalv_backend_init(jalv))) { + if (jalv_backend_open(jalv)) { jalv_log(JALV_LOG_ERR, "Failed to connect to audio system\n"); return -6; } @@ -1093,10 +1093,12 @@ jalv_deactivate(Jalv* const jalv) { if (jalv->backend) { jalv_backend_deactivate(jalv); + } + if (jalv->instance) { lilv_instance_deactivate(jalv->instance); - if (jalv->worker) { - jalv_worker_exit(jalv->worker); - } + } + if (jalv->worker) { + jalv_worker_exit(jalv->worker); } jalv->run_state = JALV_PAUSED; @@ -1181,6 +1183,7 @@ main(int argc, char** argv) { Jalv jalv; memset(&jalv, '\0', sizeof(Jalv)); + jalv.backend = jalv_backend_allocate(); // Initialize application if (jalv_open(&jalv, &argc, &argv)) { @@ -1200,5 +1203,7 @@ main(int argc, char** argv) // Deactivate audio processing and tear down application jalv_deactivate(&jalv); - return jalv_close(&jalv); + const int ret = jalv_close(&jalv); + jalv_backend_free(jalv.backend); + return ret; } |