summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2012-08-04 11:33:24 +0200
committerwm4 <wm4@nowhere>2012-08-04 19:59:56 +0200
commit6031b8e22ce34754218ddcd98d4758ab46d647b8 (patch)
treee2aad57ded8184bb538841c145c99c22983d501d
parent37c03f2c81a443e910eeb3b2613865dce59c54bf (diff)
downloadmpv-6031b8e22ce34754218ddcd98d4758ab46d647b8.tar.bz2
mpv-6031b8e22ce34754218ddcd98d4758ab46d647b8.tar.xz
m_config: implement m_config_new in terms of m_config_simple
Also change m_config_simple() such that you need to register options using m_config_register_options().
-rw-r--r--libvo/video_out.c3
-rw-r--r--m_config.c26
-rw-r--r--m_config.h3
3 files changed, 14 insertions, 18 deletions
diff --git a/libvo/video_out.c b/libvo/video_out.c
index 0466ec5fad..e81026cd52 100644
--- a/libvo/video_out.c
+++ b/libvo/video_out.c
@@ -175,8 +175,9 @@ static int vo_preinit(struct vo *vo, char *arg)
if (vo->driver->privsize)
vo->priv = talloc_zero_size(vo, vo->driver->privsize);
if (vo->driver->options) {
- struct m_config *cfg = m_config_simple(vo->driver->options, vo->priv);
+ struct m_config *cfg = m_config_simple(vo->priv);
talloc_steal(vo->priv, cfg);
+ m_config_register_options(cfg, vo->driver->options);
char n[50];
int l = snprintf(n, sizeof(n), "vo/%s", vo->driver->info->short_name);
assert(l < sizeof(n));
diff --git a/m_config.c b/m_config.c
index 075adcd633..0edf7d9023 100644
--- a/m_config.c
+++ b/m_config.c
@@ -182,11 +182,19 @@ static int config_destroy(void *p)
return 0;
}
+struct m_config *m_config_simple(void *optstruct)
+{
+ struct m_config *config = talloc_struct(NULL, struct m_config, {
+ .optstruct = optstruct,
+ });
+ talloc_set_destructor(config, config_destroy);
+ return config;
+}
+
struct m_config *m_config_new(void *optstruct,
int includefunc(struct m_config *conf,
char *filename))
{
- struct m_config *config;
static const struct m_option ref_opts[] = {
{ "profile", NULL, CONF_TYPE_STRING_LIST, CONF_NOSAVE, 0, 0, NULL },
{ "show-profile", show_profile, CONF_TYPE_PRINT_FUNC, CONF_NOCFG },
@@ -194,8 +202,8 @@ struct m_config *m_config_new(void *optstruct,
{ NULL }
};
- config = talloc_zero(NULL, struct m_config);
- talloc_set_destructor(config, config_destroy);
+ struct m_config *config = m_config_simple(optstruct);
+
struct m_option *self_opts = talloc_memdup(config, ref_opts,
sizeof(ref_opts));
for (int i = 1; self_opts[i].name; i++)
@@ -209,22 +217,10 @@ struct m_config *m_config_new(void *optstruct,
m_config_add_option(config, p, NULL, NULL);
config->includefunc = includefunc;
}
- config->optstruct = optstruct;
return config;
}
-struct m_config *m_config_simple(const struct m_option *options,
- void *optstruct)
-{
- struct m_config *config = talloc_struct(NULL, struct m_config, {
- .optstruct = optstruct,
- });
- talloc_set_destructor(config, config_destroy);
- m_config_register_options(config, options);
- return config;
-}
-
void m_config_free(struct m_config *config)
{
talloc_free(config);
diff --git a/m_config.h b/m_config.h
index 56413b60a4..3441350c0e 100644
--- a/m_config.h
+++ b/m_config.h
@@ -102,8 +102,7 @@ struct m_config *
m_config_new(void *optstruct,
int includefunc(struct m_config *conf, char *filename));
-struct m_config *m_config_simple(const struct m_option *options,
- void *optstruct);
+struct m_config *m_config_simple(void *optstruct);
// Free a config object.
void m_config_free(struct m_config *config);