summaryrefslogtreecommitdiffstats
path: root/player/command.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2019-12-16 01:47:06 +0100
committerwm4 <wm4@nowhere>2019-12-16 01:47:06 +0100
commitaa5f234b439f69c66e66fa033f443edc3055f185 (patch)
tree74bcbf31b142edcb5f201699e6e89a5eae4533db /player/command.c
parent76a92fd30b0fc12da024eb1187756d6432f8ab13 (diff)
downloadmpv-aa5f234b439f69c66e66fa033f443edc3055f185.tar.bz2
mpv-aa5f234b439f69c66e66fa033f443edc3055f185.tar.xz
command: change "edition" property behavior
See manpage/changelog changes. The purpose of this change is to removes another case of inconsistent property behavior. At first I wanted to make this go through deprecation before making a technically incompatible change, but then I considered this feature too obscure as that anyone would care.
Diffstat (limited to 'player/command.c')
-rw-r--r--player/command.c29
1 files changed, 19 insertions, 10 deletions
diff --git a/player/command.c b/player/command.c
index 1a7d5a6d20..901326b498 100644
--- a/player/command.c
+++ b/player/command.c
@@ -1040,24 +1040,32 @@ static int mp_property_list_chapters(void *ctx, struct m_property *prop,
return m_property_read_list(action, arg, count, get_chapter_entry, mpctx);
}
+static int mp_property_current_edition(void *ctx, struct m_property *prop,
+ int action, void *arg)
+{
+ MPContext *mpctx = ctx;
+ struct demuxer *demuxer = mpctx->demuxer;
+ if (!demuxer || demuxer->num_editions <= 0)
+ return M_PROPERTY_UNAVAILABLE;
+ return m_property_int_ro(action, arg, demuxer->edition);
+}
+
static int mp_property_edition(void *ctx, struct m_property *prop,
int action, void *arg)
{
MPContext *mpctx = ctx;
struct demuxer *demuxer = mpctx->demuxer;
- if (!mpctx->playback_initialized || !demuxer || demuxer->num_editions <= 0)
- return mp_property_generic_option(mpctx, prop, action, arg);
- switch (action) {
- case M_PROPERTY_GET:
- *(int *)arg = demuxer->edition;
+ if (action == M_PROPERTY_GET_CONSTRICTED_TYPE && demuxer) {
+ *(struct m_option *)arg = (struct m_option){
+ .type = CONF_TYPE_INT,
+ .flags = M_OPT_RANGE,
+ .min = 0,
+ .max = demuxer->num_editions - 1,
+ };
return M_PROPERTY_OK;
- case M_PROPERTY_GET_CONSTRICTED_TYPE: {
- int r = mp_property_generic_option(mpctx, prop, M_PROPERTY_GET_TYPE, arg);
- ((struct m_option *)arg)->max = demuxer->num_editions - 1;
- return r;
- }
}
+
return mp_property_generic_option(mpctx, prop, action, arg);
}
@@ -3273,6 +3281,7 @@ static const struct m_property mp_properties_base[] = {
{"playback-time", mp_property_playback_time},
{"chapter", mp_property_chapter},
{"edition", mp_property_edition},
+ {"current-edition", mp_property_current_edition},
{"chapters", mp_property_chapters},
{"editions", mp_property_editions},
{"metadata", mp_property_metadata},