mirror of https://github.com/mpv-player/mpv
command: alias video/audio/sub properties to -vid/-aid/-sid
Now vid/aid/sid can be used as properties. video/audio/sub still work, but they are aliases for the "real" properties. This guarantees that options/properties use the same value range. One consequence is that the video/audio/sub properties return "no" as value if no track is selected instead of -1.
This commit is contained in:
parent
497ec230bf
commit
38ce911704
|
@ -747,7 +747,7 @@ static int property_switch_track(m_option_t *prop, int action, void *arg,
|
||||||
|
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case M_PROPERTY_GET:
|
case M_PROPERTY_GET:
|
||||||
*(int *) arg = track ? track->user_tid : -1;
|
*(int *) arg = track ? track->user_tid : -2;
|
||||||
return M_PROPERTY_OK;
|
return M_PROPERTY_OK;
|
||||||
case M_PROPERTY_PRINT:
|
case M_PROPERTY_PRINT:
|
||||||
if (!track)
|
if (!track)
|
||||||
|
@ -775,9 +775,8 @@ static int property_switch_track(m_option_t *prop, int action, void *arg,
|
||||||
case M_PROPERTY_SET:
|
case M_PROPERTY_SET:
|
||||||
mp_switch_track(mpctx, type, mp_track_by_tid(mpctx, type, *(int *)arg));
|
mp_switch_track(mpctx, type, mp_track_by_tid(mpctx, type, *(int *)arg));
|
||||||
return M_PROPERTY_OK;
|
return M_PROPERTY_OK;
|
||||||
default:
|
|
||||||
return M_PROPERTY_NOT_IMPLEMENTED;
|
|
||||||
}
|
}
|
||||||
|
return mp_property_generic_option(prop, action, arg, mpctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Selected audio id (RW)
|
/// Selected audio id (RW)
|
||||||
|
@ -1303,6 +1302,19 @@ static int mp_property_tv_color(m_option_t *prop, int action, void *arg,
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
// Use option-to-property-bridge. (The property and option have the same names.)
|
// Use option-to-property-bridge. (The property and option have the same names.)
|
||||||
#define M_OPTION_PROPERTY(name) \
|
#define M_OPTION_PROPERTY(name) \
|
||||||
{(name), mp_property_generic_option, &m_option_type_dummy, 0, 0, 0, (name)}
|
{(name), mp_property_generic_option, &m_option_type_dummy, 0, 0, 0, (name)}
|
||||||
|
@ -1314,6 +1326,10 @@ static int mp_property_tv_color(m_option_t *prop, int action, void *arg,
|
||||||
#define M_OPTION_PROPERTY_CUSTOM_(name, handler, ...) \
|
#define M_OPTION_PROPERTY_CUSTOM_(name, handler, ...) \
|
||||||
{(name), (handler), &m_option_type_dummy, 0, 0, 0, (name), __VA_ARGS__}
|
{(name), (handler), &m_option_type_dummy, 0, 0, 0, (name), __VA_ARGS__}
|
||||||
|
|
||||||
|
// Redirect a property name to another
|
||||||
|
#define M_PROPERTY_ALIAS(name, real_property) \
|
||||||
|
{(name), mp_property_alias, &m_option_type_dummy, 0, 0, 0, (real_property)}
|
||||||
|
|
||||||
/// All properties available in MPlayer.
|
/// All properties available in MPlayer.
|
||||||
/** \ingroup Properties
|
/** \ingroup Properties
|
||||||
*/
|
*/
|
||||||
|
@ -1382,8 +1398,7 @@ static const m_option_t mp_properties[] = {
|
||||||
0, 0, 0, NULL },
|
0, 0, 0, NULL },
|
||||||
{ "channels", mp_property_channels, CONF_TYPE_INT,
|
{ "channels", mp_property_channels, CONF_TYPE_INT,
|
||||||
0, 0, 0, NULL },
|
0, 0, 0, NULL },
|
||||||
{ "audio", mp_property_audio, CONF_TYPE_INT,
|
M_OPTION_PROPERTY_CUSTOM("aid", mp_property_audio),
|
||||||
CONF_RANGE, -2, 65535, NULL },
|
|
||||||
{ "balance", mp_property_balance, CONF_TYPE_FLOAT,
|
{ "balance", mp_property_balance, CONF_TYPE_FLOAT,
|
||||||
M_OPT_RANGE, -1, 1, NULL },
|
M_OPT_RANGE, -1, 1, NULL },
|
||||||
|
|
||||||
|
@ -1426,14 +1441,12 @@ static const m_option_t mp_properties[] = {
|
||||||
0, 0, 0, NULL },
|
0, 0, 0, NULL },
|
||||||
{ "aspect", mp_property_aspect, CONF_TYPE_FLOAT,
|
{ "aspect", mp_property_aspect, CONF_TYPE_FLOAT,
|
||||||
CONF_RANGE, 0, 10, NULL },
|
CONF_RANGE, 0, 10, NULL },
|
||||||
{ "video", mp_property_video, CONF_TYPE_INT,
|
M_OPTION_PROPERTY_CUSTOM("vid", mp_property_video),
|
||||||
CONF_RANGE, -2, 65535, NULL },
|
|
||||||
{ "program", mp_property_program, CONF_TYPE_INT,
|
{ "program", mp_property_program, CONF_TYPE_INT,
|
||||||
CONF_RANGE, -1, 65535, NULL },
|
CONF_RANGE, -1, 65535, NULL },
|
||||||
|
|
||||||
// Subs
|
// Subs
|
||||||
{ "sub", mp_property_sub, CONF_TYPE_INT,
|
M_OPTION_PROPERTY_CUSTOM("sid", mp_property_sub),
|
||||||
M_OPT_MIN, -1, 0, NULL },
|
|
||||||
M_OPTION_PROPERTY_CUSTOM("sub-delay", mp_property_sub_delay),
|
M_OPTION_PROPERTY_CUSTOM("sub-delay", mp_property_sub_delay),
|
||||||
M_OPTION_PROPERTY_CUSTOM("sub-pos", mp_property_sub_pos),
|
M_OPTION_PROPERTY_CUSTOM("sub-pos", mp_property_sub_pos),
|
||||||
{ "sub-visibility", mp_property_sub_visibility, CONF_TYPE_FLAG,
|
{ "sub-visibility", mp_property_sub_visibility, CONF_TYPE_FLAG,
|
||||||
|
@ -1457,6 +1470,10 @@ static const m_option_t mp_properties[] = {
|
||||||
M_OPT_RANGE, -100, 100, .offset = TV_COLOR_HUE },
|
M_OPT_RANGE, -100, 100, .offset = TV_COLOR_HUE },
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
M_PROPERTY_ALIAS("video", "vid"),
|
||||||
|
M_PROPERTY_ALIAS("audio", "aid"),
|
||||||
|
M_PROPERTY_ALIAS("sub", "sid"),
|
||||||
|
|
||||||
{0},
|
{0},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue