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.
This commit is contained in:
Dudemanguy 2023-09-19 16:51:43 -05:00
parent 6ea9ec9931
commit 8a7704ea89
3 changed files with 26 additions and 3 deletions

View File

@ -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 --------------------

View File

@ -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;

View File

@ -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 };