command: don't use option name in properties

Some code accessed m_option.name to get the property name. (Maybe only
show_property_osd() had a significant use of it.) Remove that, and
remove setting names and dummy names as well.

The old code usually assumed that the name was set, and
show_property_osd() used it to get the proper name of deprecated
aliases.

The "vf" property was listed as "vf*". Not sure why that was done, but
it works without anyway.
This commit is contained in:
wm4 2014-02-21 13:18:50 +01:00
parent 0d4ec7d665
commit f225b5fc00
2 changed files with 16 additions and 34 deletions

View File

@ -37,7 +37,6 @@
const struct m_option_type m_option_type_dummy = {
.name = "Unknown",
.flags = M_OPT_TYPE_ALLOW_WILDCARD, // make "vf*" property work
};
struct legacy_prop {
@ -395,10 +394,7 @@ int m_property_read_sub(const struct m_sub_property *props, int action, void *ar
{
switch (action) {
case M_PROPERTY_GET_TYPE:
*(struct m_option *)arg = (struct m_option){
.name = "",
.type = CONF_TYPE_STRING,
};
*(struct m_option *)arg = (struct m_option){.type = CONF_TYPE_STRING};
return M_PROPERTY_OK;
case M_PROPERTY_GET:
case M_PROPERTY_PRINT: {
@ -411,7 +407,7 @@ int m_property_read_sub(const struct m_sub_property *props, int action, void *ar
const struct m_sub_property *prop = &props[n];
if (prop->unavailable)
continue;
struct m_option type = { .name = "", .type = prop->type, };
struct m_option type = {.type = prop->type};
char *s = m_option_print(&type, &prop->value);
ta_xasprintf_append(&res, "%s=%s\n", prop->name, s);
talloc_free(s);
@ -432,7 +428,7 @@ int m_property_read_sub(const struct m_sub_property *props, int action, void *ar
return M_PROPERTY_UNKNOWN;
if (prop->unavailable)
return M_PROPERTY_UNAVAILABLE;
struct m_option type = { .name = "", .type = prop->type, };
struct m_option type = {.type = prop->type};
switch (ka->action) {
case M_PROPERTY_GET: {
memset(ka->arg, 0, type.type->size);
@ -462,10 +458,7 @@ int m_property_read_list(int action, void *arg, int count,
{
switch (action) {
case M_PROPERTY_GET_TYPE:
*(struct m_option *)arg = (struct m_option){
.name = "",
.type = CONF_TYPE_STRING,
};
*(struct m_option *)arg = (struct m_option){.type = CONF_TYPE_STRING};
return M_PROPERTY_OK;
case M_PROPERTY_GET:
case M_PROPERTY_PRINT: {
@ -489,10 +482,7 @@ int m_property_read_list(int action, void *arg, int count,
if (strcmp(ka->key, "count") == 0) {
switch (ka->action) {
case M_PROPERTY_GET_TYPE: {
struct m_option opt = {
.name = "",
.type = CONF_TYPE_INT,
};
struct m_option opt = {.type = CONF_TYPE_INT};
*(struct m_option *)ka->arg = opt;
return M_PROPERTY_OK;
}

View File

@ -543,7 +543,6 @@ static int mp_property_edition(m_option_t *prop, int action, void *arg,
}
case M_PROPERTY_GET_TYPE: {
struct m_option opt = {
.name = prop->name,
.type = CONF_TYPE_INT,
.flags = CONF_RANGE,
.min = 0,
@ -757,7 +756,6 @@ static int mp_property_angle(m_option_t *prop, int action, void *arg,
return M_PROPERTY_OK;
case M_PROPERTY_GET_TYPE: {
struct m_option opt = {
.name = prop->name,
.type = CONF_TYPE_INT,
.flags = CONF_RANGE,
.min = 1,
@ -1868,7 +1866,6 @@ static int mp_property_playlist_pos(m_option_t *prop, int action, void *arg,
}
case M_PROPERTY_GET_TYPE: {
struct m_option opt = {
.name = prop->name,
.type = CONF_TYPE_INT,
.flags = CONF_RANGE,
.min = 0,
@ -1968,13 +1965,7 @@ static int mp_property_alias(m_option_t *prop, int action, void *arg,
MPContext *mpctx)
{
const char *real_property = prop->priv;
int r = mp_property_do(real_property, action, arg, mpctx);
if (action == M_PROPERTY_GET_TYPE && r >= 0) {
// Fix the property name
struct m_option *type = arg;
type->name = prop->name;
}
return r;
return mp_property_do(real_property, action, arg, mpctx);
}
static int mp_property_options(m_option_t *prop, int action, void *arg,
@ -2182,8 +2173,8 @@ static const m_option_t mp_properties[] = {
M_OPTION_PROPERTY_CUSTOM("ass-style-override", property_osd_helper),
#endif
M_OPTION_PROPERTY_CUSTOM("vf*", mp_property_vf),
M_OPTION_PROPERTY_CUSTOM("af*", mp_property_af),
M_OPTION_PROPERTY_CUSTOM("vf", mp_property_vf),
M_OPTION_PROPERTY_CUSTOM("af", mp_property_af),
#if HAVE_TV
{ "tv-brightness", mp_property_tv_color, CONF_TYPE_INT,
@ -2313,8 +2304,8 @@ static struct property_osd_display {
{ "sub-scale", "Sub Scale"},
{ "ass-vsfilter-aspect-compat", "Subtitle VSFilter aspect compat"},
{ "ass-style-override", "ASS subtitle style override"},
{ "vf*", "Video filters", .msg = "Video filters:\n${vf}"},
{ "af*", "Audio filters", .msg = "Audio filters:\n${af}"},
{ "vf", "Video filters", .msg = "Video filters:\n${vf}"},
{ "af", "Audio filters", .msg = "Audio filters:\n${af}"},
#if HAVE_TV
{ "tv-brightness", "Brightness", .osd_progbar = OSD_BRIGHTNESS },
{ "tv-hue", "Hue", .osd_progbar = OSD_HUE},
@ -2329,6 +2320,7 @@ static void show_property_osd(MPContext *mpctx, const char *pname, int osd_mode)
struct MPOpts *opts = mpctx->opts;
struct m_option prop = {0};
struct property_osd_display *p;
const char *name = pname;
if (mp_property_do(pname, M_PROPERTY_GET_TYPE, &prop, mpctx) <= 0)
return;
@ -2340,7 +2332,7 @@ static void show_property_osd(MPContext *mpctx, const char *pname, int osd_mode)
// look for the command
for (p = property_osd_display; p->name; p++) {
if (!strcmp(p->name, prop.name)) {
if (!strcmp(p->name, name)) {
osd_progbar = p->seek_bar ? 1 : p->osd_progbar;
osd_name = p->seek_msg ? "" : p->osd_name;
break;
@ -2355,7 +2347,7 @@ static void show_property_osd(MPContext *mpctx, const char *pname, int osd_mode)
}
if (osd_mode != MP_ON_OSD_AUTO) {
osd_name = osd_name ? osd_name : prop.name;
osd_name = osd_name ? osd_name : name;
if (!(osd_mode & MP_ON_OSD_MSG)) {
osd_name = NULL;
msg = NULL;
@ -2375,18 +2367,18 @@ static void show_property_osd(MPContext *mpctx, const char *pname, int osd_mode)
void *tmp = talloc_new(NULL);
if (!msg && osd_name)
msg = talloc_asprintf(tmp, "%s: ${%s}", osd_name, prop.name);
msg = talloc_asprintf(tmp, "%s: ${%s}", osd_name, name);
if (osd_progbar && (prop.flags & CONF_RANGE) == CONF_RANGE) {
bool ok = false;
if (prop.type == CONF_TYPE_INT) {
int i;
ok = mp_property_do(prop.name, M_PROPERTY_GET, &i, mpctx) > 0;
ok = mp_property_do(name, M_PROPERTY_GET, &i, mpctx) > 0;
if (ok)
set_osd_bar(mpctx, osd_progbar, osd_name, prop.min, prop.max, i);
} else if (prop.type == CONF_TYPE_FLOAT) {
float f;
ok = mp_property_do(prop.name, M_PROPERTY_GET, &f, mpctx) > 0;
ok = mp_property_do(name, M_PROPERTY_GET, &f, mpctx) > 0;
if (ok)
set_osd_bar(mpctx, osd_progbar, osd_name, prop.min, prop.max, f);
}