diff options
author | David Robillard <d@drobilla.net> | 2022-08-10 18:43:25 -0400 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2022-08-17 13:51:21 -0400 |
commit | 6867fd163dbd2594d65fc3b4b5b5b63cff4a27e9 (patch) | |
tree | a7b3ee22eaa26d0a1c4edd33ed46596927d116d4 /src | |
parent | 5043403cd31d6cc92777a90582b7520945eef1e9 (diff) | |
download | jalv-6867fd163dbd2594d65fc3b4b5b5b63cff4a27e9.tar.gz jalv-6867fd163dbd2594d65fc3b4b5b5b63cff4a27e9.tar.bz2 jalv-6867fd163dbd2594d65fc3b4b5b5b63cff4a27e9.zip |
Factor jalv_init_display() out of jalv_open()
Diffstat (limited to 'src')
-rw-r--r-- | src/jalv.c | 53 |
1 files changed, 29 insertions, 24 deletions
@@ -1076,6 +1076,34 @@ jalv_init_options(Jalv* const jalv) (void*)jalv->features.options); } +static void +jalv_init_display(Jalv* const jalv) +{ + if (!jalv->opts.update_rate) { + // Calculate a reasonable UI update frequency + jalv->ui_update_hz = jalv_frontend_refresh_rate(jalv); + } else { + // Use user-specified UI update rate + jalv->ui_update_hz = jalv->opts.update_rate; + jalv->ui_update_hz = MAX(1.0f, jalv->ui_update_hz); + } + + if (!jalv->opts.scale_factor) { + // Calculate the monitor's scale factor + jalv->ui_scale_factor = jalv_frontend_scale_factor(jalv); + } else { + // Use user-specified UI scale factor + jalv->ui_scale_factor = jalv->opts.scale_factor; + } + + // The UI can only go so fast, clamp to reasonable limits + jalv->ui_update_hz = MIN(60, jalv->ui_update_hz); + jalv->opts.buffer_size = MAX(4096, jalv->opts.buffer_size); + jalv_log(JALV_LOG_INFO, "Comm buffers: %u bytes\n", jalv->opts.buffer_size); + jalv_log(JALV_LOG_INFO, "Update rate: %.01f Hz\n", jalv->ui_update_hz); + jalv_log(JALV_LOG_INFO, "Scale factor: %.01f\n", jalv->ui_scale_factor); +} + int jalv_open(Jalv* const jalv, int* argc, char*** argv) { @@ -1271,30 +1299,7 @@ jalv_open(Jalv* const jalv, int* argc, char*** argv) jalv->opts.buffer_size = jalv->midi_buf_size * N_BUFFER_CYCLES; } - if (!jalv->opts.update_rate) { - // Calculate a reasonable UI update frequency - jalv->ui_update_hz = jalv_frontend_refresh_rate(jalv); - } else { - // Use user-specified UI update rate - jalv->ui_update_hz = jalv->opts.update_rate; - jalv->ui_update_hz = MAX(1.0f, jalv->ui_update_hz); - } - - if (!jalv->opts.scale_factor) { - // Calculate the monitor's scale factor - jalv->ui_scale_factor = jalv_frontend_scale_factor(jalv); - } else { - // Use user-specified UI scale factor - jalv->ui_scale_factor = jalv->opts.scale_factor; - } - - // The UI can only go so fast, clamp to reasonable limits - jalv->ui_update_hz = MIN(60, jalv->ui_update_hz); - jalv->opts.buffer_size = MAX(4096, jalv->opts.buffer_size); - jalv_log(JALV_LOG_INFO, "Comm buffers: %u bytes\n", jalv->opts.buffer_size); - jalv_log(JALV_LOG_INFO, "Update rate: %.01f Hz\n", jalv->ui_update_hz); - jalv_log(JALV_LOG_INFO, "Scale factor: %.01f\n", jalv->ui_scale_factor); - + jalv_init_display(jalv); jalv_init_options(jalv); // Create Plugin <=> UI communication buffers |