summaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
authorVito Caputo <vcaputo@pengaru.com>2023-11-30 11:34:15 -0800
committerVito Caputo <vcaputo@pengaru.com>2023-11-30 11:44:14 -0800
commit28d12a899645be09dae7e4cb8c293bf7fc64d6ad (patch)
treead195d50f3d488521add9f81f7fd291fc7d92743 /src/main.c
parent97b3dd17c1499c7ffd6d429a01d64ceaed233df2 (diff)
til: wire up til_video_setup_t throughout *_fb
Preparatory commit for aspect ratio settings at the fb layer. This slightly reworks how main::setup_video() integrates the selected fb backend's setup_func to better resemble how the module setup_funcs work now, with more clearly separated settings-building and setup-baking/finalizing phases. Which makes inserting the ratio setting in the middle of the front-end and back-end setup_funcs fairly trivial. Not a fan of all the casts, but there will probably be more helpers introduced to take care of that and make til_video_setup_t more of a first-class thing facilitating the fb stuff.
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c56
1 files changed, 33 insertions, 23 deletions
diff --git a/src/main.c b/src/main.c
index c4e4c4e..df2d219 100644
--- a/src/main.c
+++ b/src/main.c
@@ -17,6 +17,7 @@
#include "til_settings.h"
#include "til_stream.h"
#include "til_util.h"
+#include "til_video_setup.h"
#include "fps.h"
#include "setup.h"
@@ -80,14 +81,14 @@ static rototiller_t rototiller;
typedef struct setup_t {
- til_settings_t *module_settings;
- til_setup_t *module_setup;
- til_settings_t *audio_settings;
- til_setup_t *audio_setup;
- til_settings_t *video_settings;
- til_setup_t *video_setup;
- unsigned seed;
- const char *title;
+ til_settings_t *module_settings;
+ til_setup_t *module_setup;
+ til_settings_t *audio_settings;
+ til_setup_t *audio_setup;
+ til_settings_t *video_settings;
+ til_video_setup_t *video_setup;
+ unsigned seed;
+ const char *title;
} setup_t;
/* FIXME: this is unnecessarily copy-pasta, i think modules should just be made
@@ -153,6 +154,7 @@ static int setup_video(const til_settings_t *settings, til_setting_t **res_setti
{
til_setting_t *setting;
const char *video;
+ int r;
video = til_settings_get_value_by_idx(settings, 0, &setting);
if (!video || !setting->desc) {
@@ -166,7 +168,6 @@ static int setup_video(const til_settings_t *settings, til_setting_t **res_setti
#endif
NULL,
};
- int r;
r = til_setting_desc_new( settings,
&(til_setting_spec_t){
@@ -189,26 +190,35 @@ static int setup_video(const til_settings_t *settings, til_setting_t **res_setti
/* XXX: this is kind of hacky for now */
#ifdef HAVE_DRM
- if (!strcasecmp(video, "drm")) {
+ if (!strcasecmp(video, "drm"))
fb_ops = &drm_fb_ops;
-
- return drm_fb_ops.setup(settings, res_setting, res_desc, res_setup);
- }
#endif
- if (!strcasecmp(video, "mem")) {
+ if (!strcasecmp(video, "mem"))
fb_ops = &mem_fb_ops;
-
- return mem_fb_ops.setup(settings, res_setting, res_desc, res_setup);
- }
#ifdef HAVE_SDL
- if (!strcasecmp(video, "sdl")) {
+ if (!strcasecmp(video, "sdl"))
fb_ops = &sdl_fb_ops;
+#endif
+ if (!fb_ops) {
+ *res_setting = setting;
+ return -EINVAL;
+ }
- return sdl_fb_ops.setup(settings, res_setting, res_desc, res_setup);
+ r = fb_ops->setup(settings, res_setting, res_desc, NULL);
+ if (r)
+ return r;
+
+ if (res_setup) { /* now to finalize/bake the setup */
+ til_video_setup_t *setup;
+
+ r = fb_ops->setup(settings, res_setting, res_desc, (til_setup_t **)&setup);
+ if (r)
+ return r;
+
+ *res_setup = &setup->til_setup;
}
-#endif
- return -EINVAL;
+ return 0;
}
@@ -319,7 +329,7 @@ static int setup_from_args(til_args_t *args, setup_t *res_setup, const char **re
if (r)
changes = 1;
- r = setup_interactively(setup.video_settings, setup_video, args->use_defaults, &setup.video_setup, res_failed_desc_path);
+ r = setup_interactively(setup.video_settings, setup_video, args->use_defaults, (til_setup_t **)&setup.video_setup, res_failed_desc_path);
if (r < 0)
goto _err;
if (r)
@@ -531,7 +541,7 @@ int main(int argc, const char *argv[])
{ /* free setup (move to function? and disambiguate from til_setup_t w/rename? TODO) */
free((void *)setup.title);
- til_setup_free(setup.video_setup);
+ til_setup_free(&setup.video_setup->til_setup);
til_settings_free(setup.video_settings);
til_setup_free(setup.audio_setup);
til_settings_free(setup.audio_settings);
© All Rights Reserved