diff options
author | David Robillard <d@drobilla.net> | 2024-11-18 09:18:50 -0500 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2024-11-24 19:08:02 -0500 |
commit | 5a16e2d8cb8e9db9b48a7baa79a8cbfbb1fd7697 (patch) | |
tree | b480610ea2f9264dd03c215a183fd061bc85b95a /src/jalv.c | |
parent | 64f74f51f864ef8cf40f026013a2e466e7fc9066 (diff) | |
download | jalv-5a16e2d8cb8e9db9b48a7baa79a8cbfbb1fd7697.tar.gz jalv-5a16e2d8cb8e9db9b48a7baa79a8cbfbb1fd7697.tar.bz2 jalv-5a16e2d8cb8e9db9b48a7baa79a8cbfbb1fd7697.zip |
Move main() and related code to a separate file
Diffstat (limited to 'src/jalv.c')
-rw-r--r-- | src/jalv.c | 59 |
1 files changed, 0 insertions, 59 deletions
@@ -37,7 +37,6 @@ #include "lv2/urid/urid.h" #include "lv2/worker/worker.h" #include "zix/allocator.h" -#include "zix/attributes.h" #include "zix/filesystem.h" #include "zix/ring.h" #include "zix/sem.h" @@ -47,7 +46,6 @@ # include "suil/suil.h" #endif -#include <signal.h> #include <stdbool.h> #include <stdint.h> #include <stdio.h> @@ -64,8 +62,6 @@ */ #define N_BUFFER_CYCLES 16 -static ZixSem* exit_sem = NULL; ///< Exit semaphore used by signal handler - /// These features have no data static const LV2_Feature static_features[] = { {LV2_STATE__loadDefaultState, NULL}, @@ -578,37 +574,12 @@ jalv_apply_control_arg(Jalv* jalv, const char* s) } static void -signal_handler(int ZIX_UNUSED(sig)) -{ - zix_sem_post(exit_sem); -} - -static void init_feature(LV2_Feature* const dest, const char* const URI, void* data) { dest->URI = URI; dest->data = data; } -static void -setup_signals(Jalv* const jalv) -{ - exit_sem = &jalv->done; - -#if !defined(_WIN32) && USE_SIGACTION - struct sigaction action; - sigemptyset(&action.sa_mask); - action.sa_flags = 0; - action.sa_handler = signal_handler; - sigaction(SIGINT, &action, NULL); - sigaction(SIGTERM, &action, NULL); -#else - // May not work in combination with fgets in the console interface - signal(SIGINT, signal_handler); - signal(SIGTERM, signal_handler); -#endif -} - static const LilvUI* jalv_select_custom_ui(const Jalv* const jalv) { @@ -1177,33 +1148,3 @@ jalv_close(Jalv* const jalv) return 0; } - -int -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)) { - jalv_close(&jalv); - return EXIT_FAILURE; - } - - // Set up signal handlers and activate audio processing - setup_signals(&jalv); - jalv_activate(&jalv); - - // Run UI (or prompt at console) - jalv_frontend_open(&jalv); - - // Wait for finish signal from UI or signal handler - zix_sem_wait(&jalv.done); - - // Deactivate audio processing and tear down application - jalv_deactivate(&jalv); - const int ret = jalv_close(&jalv); - jalv_backend_free(jalv.backend); - return ret; -} |