diff --git a/inc/lektor/config.def b/inc/lektor/config.def index e32c0f78000a0ce91c3712dfad0448c69758b937..3f222fd4a9fdccfb2c0c834c9f17f483d98911a6 100644 --- a/inc/lektor/config.def +++ b/inc/lektor/config.def @@ -38,6 +38,7 @@ value("def_repeat", "false") value("font_size", "20") value("font_name", "Hack Nerd Font") value("msg_duration", "4") +value_opt("force_x11", "1") /* Force libmpv to use x11, may segfault on some PCs... */ /* To place hooks, when some things are done in lektor. The default value 'none' is here so that nothing happens. Like any module, the value can point to a module or a function in the internal diff --git a/src/module/mpv.c b/src/module/mpv.c index 67735f98e43f94a29cb4ed877be4f1451960be6e..4d6da5ae16f9c5203f8f6ff1add22161870bb6ed 100644 --- a/src/module/mpv.c +++ b/src/module/mpv.c @@ -29,27 +29,38 @@ lmpv_prepare(volatile sqlite3 *db) RETURN_UNLESS(ctx, "Failed to create context", NULL); char _opt[LKT_LINE_MAX]; -#define MPV_SET_OPTION(opt, value) \ - if ((status = mpv_set_option_string(ctx, opt, value)) < 0) { \ - LOG_ERROR("WINDOW", "Failed to set %s to %s: %s", \ - opt, value, mpv_error_string(status)); \ - return NULL; \ +#define MPV_SET_OPTION(opt, value) \ + if ((status = mpv_set_option_string(ctx, opt, value)) < 0) { \ + LOG_ERROR("WINDOW", "Failed to set %s to %s: %s", \ + opt, value, mpv_error_string(status)); \ + return NULL; \ } -#define MPV_SET_FROM_INI(opt, section, key) \ - if (!database_config_get_text(db, section, key, _opt, LKT_LINE_MAX)) { \ - LOG_WARN("WINDOW", "Failed to get option " \ - key " in section " section); \ - return ctx; \ - } \ +#define MPV_SET_FROM_INI(opt, section, key) \ + if (!database_config_get_text(db, section, key, _opt, LKT_LINE_MAX)) { \ + LOG_WARN("WINDOW", "Failed to get option " \ + key " in section " section); \ + return ctx; \ + } \ MPV_SET_OPTION(opt, _opt); +#define MPV_SET_OPTION_COND(opt, value, ini_section, ini_option, def) ({ \ + int ___cond; \ + if (!database_config_get_int(db, ini_section, ini_option, &___cond)) { \ + LOG_WARN("WINDOW", "Using default value '" #def "' because [" \ + #ini_section "->" #ini_option "] was not present in ini " \ + "config file"); \ + ___cond = (def); \ + } \ + if (___cond) \ + MPV_SET_OPTION(opt, value); \ + }) MPV_SET_OPTION("input-default-bindings", "yes"); MPV_SET_OPTION("input-vo-keyboard", "yes"); MPV_SET_OPTION("replaygain", "track"); - MPV_SET_OPTION("gpu-context", "x11"); /* Wayland you sucks */ MPV_SET_OPTION("demuxer-readahead-secs", "5.0"); MPV_SET_OPTION("demuxer-max-bytes", "100M"); MPV_SET_OPTION("hwdec", "yes"); + MPV_SET_OPTION_COND("gpu-context", "x11", "player", "force_x11", 1); /* Wayland you sucks */ MPV_SET_FROM_INI("osd-font-size", "player", "font_size"); MPV_SET_FROM_INI("osd-font", "player", "font_name"); MPV_SET_FROM_INI("osd-duration", "player", "msg_duration");