From 8a7704ea8928f0a7342757e89c64f022a21cdef8 Mon Sep 17 00:00:00 2001 From: Dudemanguy Date: Tue, 19 Sep 2023 16:51:43 -0500 Subject: [PATCH] stream_bluray: move --bluray-device to stream_bluray_opts Similar to the previous commit. There's no reason for --bluray-device to be in MPOpts. Make a specific subopt for stream_bluray and use that instead so we can remove the mp_read_option_raw call. --- options/options.c | 3 ++- options/options.h | 1 + stream/stream_bluray.c | 25 +++++++++++++++++++++++-- 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/options/options.c b/options/options.c index c6a0873b31..523f172298 100644 --- a/options/options.c +++ b/options/options.c @@ -56,6 +56,7 @@ static void print_version(struct mp_log *log) } extern const struct m_sub_options tv_params_conf; +extern const struct m_sub_options stream_bluray_conf; extern const struct m_sub_options stream_cdda_conf; extern const struct m_sub_options stream_dvb_conf; extern const struct m_sub_options stream_lavf_conf; @@ -483,7 +484,7 @@ static const m_option_t mp_opts[] = { #endif {"edition", OPT_CHOICE(edition_id, {"auto", -1}), M_RANGE(0, 8190)}, #if HAVE_LIBBLURAY - {"bluray-device", OPT_STRING(bluray_device), .flags = M_OPT_FILE}, + {"bluray", OPT_SUBSTRUCT(stream_bluray_opts, stream_bluray_conf)}, #endif /* HAVE_LIBBLURAY */ // ------------------------- demuxer options -------------------- diff --git a/options/options.h b/options/options.h index 6f3d80239f..498d4aae85 100644 --- a/options/options.h +++ b/options/options.h @@ -321,6 +321,7 @@ typedef struct MPOpts { int w32_priority; + struct bluray_opts *stream_bluray_opts; struct cdda_params *stream_cdda_opts; struct dvb_params *stream_dvb_opts; struct stream_lavf_params *stream_lavf_opts; diff --git a/stream/stream_bluray.c b/stream/stream_bluray.c index 19e99a458b..7771375aa2 100644 --- a/stream/stream_bluray.c +++ b/stream/stream_bluray.c @@ -73,6 +73,20 @@ #define AACS_ERROR_MMC_FAILURE -7 /* MMC failed */ #define AACS_ERROR_NO_DK -8 /* no matching device key */ + +struct bluray_opts { + char *bluray_device; +}; + +#define OPT_BASE_STRUCT struct bluray_opts +const struct m_sub_options stream_bluray_conf = { + .opts = (const struct m_option[]) { + {"device", OPT_STRING(bluray_device), .flags = M_OPT_FILE}, + {0}, + }, + .size = sizeof(struct bluray_opts), +}; + struct bluray_priv_s { BLURAY *bd; BLURAY_TITLE_INFO *title_info; @@ -86,6 +100,8 @@ struct bluray_priv_s { char *cfg_device; bool use_nav; + struct bluray_opts *opts; + struct m_config_cache *opts_cache; }; static void destruct(struct bluray_priv_s *priv) @@ -377,8 +393,7 @@ static int bluray_stream_open_internal(stream_t *s) if (b->cfg_device && b->cfg_device[0]) { device = b->cfg_device; } else { - mp_read_option_raw(s->global, "bluray-device", &m_option_type_string, - &device); + device = b->opts->bluray_device; } if (!device || !device[0]) { @@ -466,6 +481,12 @@ static int bluray_stream_open(stream_t *s) struct bluray_priv_s *b = talloc_zero(s, struct bluray_priv_s); s->priv = b; + struct m_config_cache *opts_cache = + m_config_cache_alloc(s, s->global, &stream_bluray_conf); + + b->opts_cache = opts_cache; + b->opts = opts_cache->opts; + b->use_nav = s->info == &stream_info_bdnav; bstr title, bdevice, rest = { .len = 0 };