mirror of
https://github.com/mpv-player/mpv
synced 2025-03-21 10:51:51 +00:00
options: add mechanism to add sub-options from component lists
There are a lot of ad-hoc component lists in mpv: for example the stream and demuxer lists. It doesn't seem to make sense to add any abstractions around it since they are completely trivial and have very specific probing mechanisms and so on, so they will remain ad-hoc. This commits add a way to let these add arbitrary per-component options, without giving up the ad-hoc way, and without having to dump them into options.c with lots of ifdeffery (like it was done until now). Also see next commit.
This commit is contained in:
parent
4419d29bb0
commit
8150b8552b
options
@ -708,6 +708,16 @@ static void add_sub_group(struct m_config_shadow *shadow, const char *name_prefi
|
||||
}
|
||||
}
|
||||
|
||||
if (subopts->get_sub_options) {
|
||||
for (int i = 0; ; i++) {
|
||||
const struct m_sub_options *sub = NULL;
|
||||
if (!subopts->get_sub_options(i, &sub))
|
||||
break;
|
||||
if (sub)
|
||||
add_sub_group(shadow, NULL, group_index, -1, sub);
|
||||
}
|
||||
}
|
||||
|
||||
shadow->groups[group_index].group_count = shadow->num_groups - group_index;
|
||||
}
|
||||
|
||||
|
@ -204,6 +204,11 @@ struct m_sub_options {
|
||||
// Change flags passed to mp_option_change_callback() if any option that is
|
||||
// directly or indirectly part of this group is changed.
|
||||
int change_flags;
|
||||
// Return further sub-options, for example for optional components. If set,
|
||||
// this is called with increasing index (starting from 0), as long as true
|
||||
// is returned. If true is returned and *sub is set in any of these calls,
|
||||
// they are added as options.
|
||||
bool (*get_sub_options)(int index, const struct m_sub_options **sub);
|
||||
};
|
||||
|
||||
#define CONF_TYPE_FLAG (&m_option_type_flag)
|
||||
|
Loading…
Reference in New Issue
Block a user