summaryrefslogtreecommitdiffstats
path: root/options
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2016-09-09 17:44:02 +0200
committerwm4 <wm4@nowhere>2016-09-09 17:54:57 +0200
commit04320d26ebb8a9ea2cfba9a7b6ddec0920326233 (patch)
tree2908ca8415f17ae9ed687797a9b8acddf8cccf71 /options
parentc15764101943e93ea9e8223596d8a6a2571494c3 (diff)
downloadmpv-04320d26ebb8a9ea2cfba9a7b6ddec0920326233.tar.bz2
mpv-04320d26ebb8a9ea2cfba9a7b6ddec0920326233.tar.xz
stream, demux, config: remove some dead/unneeded option-related code
This has all been made unnecessary recently. The change not to copy the global option struct in particular can be made because now nothing accesses the global options anymore in the demux and stream layers. Some code that was accidentally added/changed in commit 5e30e7a0 is also removed, because it was simply committed accidentally, and was never used.
Diffstat (limited to 'options')
-rw-r--r--options/m_config.c68
-rw-r--r--options/m_config.h9
2 files changed, 5 insertions, 72 deletions
diff --git a/options/m_config.c b/options/m_config.c
index 695c9569e9..f4d544c798 100644
--- a/options/m_config.c
+++ b/options/m_config.c
@@ -411,8 +411,11 @@ static void add_sub_options(struct m_config *config,
assert(config->groups[n].group != subopts);
void *new_optstruct = NULL;
- if (config->optstruct) // only if not noalloc
- new_optstruct = m_config_alloc_struct(config, subopts);
+ if (config->optstruct) { // only if not noalloc
+ new_optstruct = talloc_zero_size(config, subopts->size);
+ if (subopts->defaults)
+ memcpy(new_optstruct, subopts->defaults, subopts->size);
+ }
if (parent && parent->data)
substruct_write_ptr(parent->data, new_optstruct);
@@ -1270,67 +1273,6 @@ struct m_config *mp_get_root_config(struct mpv_global *global)
return global->config->root;
}
-void *m_config_alloc_struct(void *talloc_ctx,
- const struct m_sub_options *subopts)
-{
- void *substruct = talloc_zero_size(talloc_ctx, subopts->size);
- if (subopts->defaults)
- memcpy(substruct, subopts->defaults, subopts->size);
- return substruct;
-}
-
-struct dtor_info {
- const struct m_sub_options *opts;
- void *ptr;
-};
-
-static void free_substruct(void *ptr)
-{
- struct dtor_info *d = ptr;
- for (int n = 0; d->opts->opts && d->opts->opts[n].type; n++) {
- const struct m_option *opt = &d->opts->opts[n];
- void *dst = (char *)d->ptr + opt->offset;
- m_option_free(opt, dst);
- }
-}
-
-// Passing ptr==NULL initializes it from proper defaults.
-void *m_sub_options_copy(void *talloc_ctx, const struct m_sub_options *opts,
- const void *ptr)
-{
- void *new = m_config_alloc_struct(talloc_ctx, opts);
- struct dtor_info *dtor = talloc_ptrtype(new, dtor);
- *dtor = (struct dtor_info){opts, new};
- talloc_set_destructor(dtor, free_substruct);
- for (int n = 0; opts->opts && opts->opts[n].type; n++) {
- const struct m_option *opt = &opts->opts[n];
- if (opt->offset < 0)
- continue;
- void *src = ptr ? (char *)ptr + opt->offset : NULL;
- void *dst = (char *)new + opt->offset;
- if (opt->type->flags & M_OPT_TYPE_HAS_CHILD) {
- // Specifying a default struct for a sub-option field in the
- // containing struct's default struct is not supported here.
- // (Out of laziness. Could possibly be supported.)
- assert(!substruct_read_ptr(dst));
-
- const struct m_sub_options *subopts = opt->priv;
-
- const void *sub_src = NULL;
- if (src)
- sub_src = substruct_read_ptr(src);
- if (!sub_src)
- sub_src = subopts->defaults;
-
- void *sub_dst = m_sub_options_copy(new, subopts, sub_src);
- substruct_write_ptr(dst, sub_dst);
- } else {
- init_opt_inplace(opt, dst, src);
- }
- }
- return new;
-}
-
struct m_config *m_config_dup(void *talloc_ctx, struct m_config *config)
{
struct m_config *new = m_config_new(talloc_ctx, config->log, config->size,
diff --git a/options/m_config.h b/options/m_config.h
index 1e23a2b0dd..ec9eb21ae2 100644
--- a/options/m_config.h
+++ b/options/m_config.h
@@ -272,15 +272,6 @@ int m_config_set_profile(struct m_config *config, char *name, int flags);
struct mpv_node m_config_get_profiles(struct m_config *config);
-void *m_config_alloc_struct(void *talloc_ctx,
- const struct m_sub_options *subopts);
-
-// Create a copy of the struct ptr, described by opts.
-// "opts" must live until the struct is free'd.
-// Freeing the struct frees all members.
-void *m_sub_options_copy(void *talloc_ctx, const struct m_sub_options *opts,
- const void *ptr);
-
// This can be used to create and synchronize per-thread option structs,
// which then can be read without synchronization. No concurrent access to
// the cache itself is allowed.