mirror of https://github.com/mpv-player/mpv
command: make empty vf-metadata not an error
If a filter exists, but has no metadata, just return success. This allows the user to distinguish between no metadata available, and filter not inserted. See #1408.
This commit is contained in:
parent
f2d6c8cb1c
commit
63a414c708
|
@ -1075,8 +1075,10 @@ static int tag_property(int action, void *arg, struct mp_tags *tags)
|
||||||
res = talloc_asprintf_append_buffer(res, "%s: %s\n",
|
res = talloc_asprintf_append_buffer(res, "%s: %s\n",
|
||||||
tags->keys[n], tags->values[n]);
|
tags->keys[n], tags->values[n]);
|
||||||
}
|
}
|
||||||
|
if (!res)
|
||||||
|
res = talloc_strdup(NULL, "(empty)");
|
||||||
*(char **)arg = res;
|
*(char **)arg = res;
|
||||||
return res ? M_PROPERTY_OK : M_PROPERTY_UNAVAILABLE;
|
return M_PROPERTY_OK;
|
||||||
}
|
}
|
||||||
case M_PROPERTY_KEY_ACTION: {
|
case M_PROPERTY_KEY_ACTION: {
|
||||||
struct m_property_action_arg *ka = arg;
|
struct m_property_action_arg *ka = arg;
|
||||||
|
@ -1153,22 +1155,16 @@ static int mp_property_vf_metadata(void *ctx, struct m_property *prop,
|
||||||
return M_PROPERTY_UNAVAILABLE;
|
return M_PROPERTY_UNAVAILABLE;
|
||||||
struct vf_chain *vf = mpctx->d_video->vfilter;
|
struct vf_chain *vf = mpctx->d_video->vfilter;
|
||||||
|
|
||||||
switch(action) {
|
if (action == M_PROPERTY_KEY_ACTION) {
|
||||||
case M_PROPERTY_GET_TYPE:
|
|
||||||
case M_PROPERTY_GET:
|
|
||||||
case M_PROPERTY_GET_NODE:
|
|
||||||
return M_PROPERTY_NOT_IMPLEMENTED;
|
|
||||||
case M_PROPERTY_KEY_ACTION: {
|
|
||||||
struct m_property_action_arg *ka = arg;
|
struct m_property_action_arg *ka = arg;
|
||||||
bstr key;
|
bstr key;
|
||||||
char *rem;
|
char *rem;
|
||||||
m_property_split_path(ka->key, &key, &rem);
|
m_property_split_path(ka->key, &key, &rem);
|
||||||
struct mp_tags vf_metadata;
|
struct mp_tags vf_metadata = {0};
|
||||||
switch (vf_control_by_label(vf, VFCTRL_GET_METADATA, &vf_metadata, key)) {
|
switch (vf_control_by_label(vf, VFCTRL_GET_METADATA, &vf_metadata, key)) {
|
||||||
case CONTROL_NA:
|
|
||||||
return M_PROPERTY_UNAVAILABLE;
|
|
||||||
case CONTROL_UNKNOWN:
|
case CONTROL_UNKNOWN:
|
||||||
return M_PROPERTY_UNKNOWN;
|
return M_PROPERTY_UNKNOWN;
|
||||||
|
case CONTROL_NA: // empty
|
||||||
case CONTROL_OK:
|
case CONTROL_OK:
|
||||||
if (strlen(rem)) {
|
if (strlen(rem)) {
|
||||||
struct m_property_action_arg next_ka = *ka;
|
struct m_property_action_arg next_ka = *ka;
|
||||||
|
@ -1182,7 +1178,6 @@ static int mp_property_vf_metadata(void *ctx, struct m_property *prop,
|
||||||
return M_PROPERTY_ERROR;
|
return M_PROPERTY_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return M_PROPERTY_NOT_IMPLEMENTED;
|
return M_PROPERTY_NOT_IMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -170,10 +170,11 @@ int vf_control_by_label(struct vf_chain *c,int cmd, void *arg, bstr label)
|
||||||
char *label_str = bstrdup0(NULL, label);
|
char *label_str = bstrdup0(NULL, label);
|
||||||
struct vf_instance *cur = vf_find_by_label(c, label_str);
|
struct vf_instance *cur = vf_find_by_label(c, label_str);
|
||||||
talloc_free(label_str);
|
talloc_free(label_str);
|
||||||
if (cur && cur->control)
|
if (cur) {
|
||||||
return cur->control(cur, cmd, arg);
|
return cur->control ? cur->control(cur, cmd, arg) : CONTROL_NA;
|
||||||
else
|
} else {
|
||||||
return CONTROL_UNKNOWN;
|
return CONTROL_UNKNOWN;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void vf_control_all(struct vf_chain *c, int cmd, void *arg)
|
static void vf_control_all(struct vf_chain *c, int cmd, void *arg)
|
||||||
|
|
Loading…
Reference in New Issue