summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2016-09-01 20:57:33 +0200
committerwm4 <wm4@nowhere>2016-09-01 20:57:33 +0200
commit1393d79417278dfa63a7a5c767093eaf3504edce (patch)
tree3a33c48248a5a32daecbe8f2a8f98c7c7c010fca
parent192a7344d91de24d486effba73383b1c2790acc2 (diff)
downloadmpv-1393d79417278dfa63a7a5c767093eaf3504edce.tar.bz2
mpv-1393d79417278dfa63a7a5c767093eaf3504edce.tar.xz
command: fix or document some property/option consistency issues
Make some existing properties behave more like options. This mostly means they don't deny access if the associated component is not active, but redirects to the option. One kind of fishy change is that we apply --brightness etc. only if they're not set to the default value. This won't necessarily work with --vo=xv, but affects only cases where 1. the Xv adapter has been changed to non-defaults, and 2. the user tries to reset them with mpv by passing e.g. --brightness=0. We don't care about Xv, and the noted use-case is dumb, so this change is acceptable.
-rw-r--r--DOCS/interface-changes.rst4
-rw-r--r--DOCS/man/input.rst36
-rw-r--r--options/options.c10
-rw-r--r--player/command.c27
-rw-r--r--player/video.c10
5 files changed, 61 insertions, 26 deletions
diff --git a/DOCS/interface-changes.rst b/DOCS/interface-changes.rst
index 478285a394..9bfbdcf3b0 100644
--- a/DOCS/interface-changes.rst
+++ b/DOCS/interface-changes.rst
@@ -26,7 +26,9 @@ Interface changes
but do not use the mechanism for negation options.
(Also see client API change for API version 1.23.)
- add almost all options to the property list, meaning you can change
- options without adding "options/" to the property name
+ options without adding "options/" to the property name (a new section
+ has been added to the manpage describing some conflicting behavior
+ between options and properties)
- rename the following properties
- "demuxer" -> "current-demuxer"
- "fps" -> "container-fps"
diff --git a/DOCS/man/input.rst b/DOCS/man/input.rst
index baeb1703d9..56fa6b355e 100644
--- a/DOCS/man/input.rst
+++ b/DOCS/man/input.rst
@@ -2062,6 +2062,42 @@ Property list
is not a map, as order matters and duplicate entries are possible. Recursive
profiles are not expanded, and show up as special ``profile`` options.
+Inconsistencies between options and properties
+----------------------------------------------
+
+You can access (almost) all options as properties, though there are some
+caveats with some properties (due to historical reasons):
+
+``vid``, ``aid``, ``sid``
+ While playback is active, you can set existing tracks only. (The option
+ allows setting any track ID, and which tracks to enable is chosen at
+ loading time.)
+
+``deinterlace``
+ While video is active, this behaves differently from the option. It will
+ never return the ``auto`` value (but the state as observed by the video
+ chain). You cannot set ``auto`` either.
+
+``video-aspect``
+ While video is active, always returns the effective aspect ratio.
+
+``brightness`` (and other color options)
+ If ``--vo=xv`` is used, these properties may return the adapter's current
+ values instead of the option values.
+
+``display-fps``
+ If a VO is created, this will return either the actual display FPS, or
+ an invalid value, instead of the option value.
+
+``cache``
+ This behaves completely different as property: instead of configuring the
+ cache size like the option, it returns the cache state in percent.
+
+``demuxer``, ``idle``, ``length``, ``audio-samplerate``, ``audio-channels``, ``audio-format``, ``fps``
+ These behave completely different as property, but are deprecated (newer
+ aliases which don't conflict have been added). After the deprecation period
+ they will be changed to the proper option behavior.
+
Property Expansion
------------------
diff --git a/options/options.c b/options/options.c
index 2aff813a25..9c3ec0b776 100644
--- a/options/options.c
+++ b/options/options.c
@@ -746,11 +746,11 @@ const struct MPOpts mp_default_opts = {
.heartbeat_interval = 30.0,
.stop_screensaver = 1,
.cursor_autohide_delay = 1000,
- .gamma_gamma = 1000,
- .gamma_brightness = 1000,
- .gamma_contrast = 1000,
- .gamma_saturation = 1000,
- .gamma_hue = 1000,
+ .gamma_gamma = 0,
+ .gamma_brightness = 0,
+ .gamma_contrast = 0,
+ .gamma_saturation = 0,
+ .gamma_hue = 0,
.video_osd = 1,
.osd_level = 1,
.osd_duration = 1000,
diff --git a/player/command.c b/player/command.c
index e5cbe2c84f..17e320cd06 100644
--- a/player/command.c
+++ b/player/command.c
@@ -477,10 +477,7 @@ static int mp_property_stream_capture(void *ctx, struct m_property *prop,
int action, void *arg)
{
MPContext *mpctx = ctx;
- if (!mpctx->demuxer)
- return M_PROPERTY_UNAVAILABLE;
-
- if (action == M_PROPERTY_SET) {
+ if (mpctx->demuxer && action == M_PROPERTY_SET) {
struct change_stream_capture_args args = {*(char **)arg, mpctx->demuxer};
demux_run_on_thread(mpctx->demuxer, do_change_stream_capture, &args);
// fall through to mp_property_generic_option
@@ -811,6 +808,9 @@ static int mp_property_chapter(void *ctx, struct m_property *prop,
int action, void *arg)
{
MPContext *mpctx = ctx;
+ if (!mpctx->playback_initialized)
+ return mp_property_generic_option(mpctx, prop, action, arg);
+
int chapter = get_current_chapter(mpctx);
int num = get_chapter_count(mpctx);
if (chapter < -1)
@@ -928,7 +928,9 @@ static int mp_property_edition(void *ctx, struct m_property *prop,
int action, void *arg)
{
MPContext *mpctx = ctx;
- struct MPOpts *opts = mpctx->opts;
+ if (!mpctx->playback_initialized)
+ return mp_property_generic_option(mpctx, prop, action, arg);
+
struct demuxer *demuxer = mpctx->demuxer;
if (!demuxer)
return M_PROPERTY_UNAVAILABLE;
@@ -944,7 +946,7 @@ static int mp_property_edition(void *ctx, struct m_property *prop,
case M_PROPERTY_SET: {
edition = *(int *)arg;
if (edition != demuxer->edition) {
- opts->edition_id = edition;
+ mpctx->opts->edition_id = edition;
if (!mpctx->stop_play)
mpctx->stop_play = PT_RELOAD_FILE;
}
@@ -1312,7 +1314,7 @@ static int mp_property_pause(void *ctx, struct m_property *prop,
{
MPContext *mpctx = ctx;
- if (action == M_PROPERTY_SET) {
+ if (mpctx->playback_initialized && action == M_PROPERTY_SET) {
if (*(int *)arg) {
pause_player(mpctx);
} else {
@@ -1800,8 +1802,6 @@ static int mp_property_audio_delay(void *ctx, struct m_property *prop,
int action, void *arg)
{
MPContext *mpctx = ctx;
- if (!(mpctx->ao_chain && mpctx->vo_chain))
- return M_PROPERTY_UNAVAILABLE;
float delay = mpctx->opts->audio_delay;
switch (action) {
case M_PROPERTY_PRINT:
@@ -1809,7 +1809,8 @@ static int mp_property_audio_delay(void *ctx, struct m_property *prop,
return M_PROPERTY_OK;
case M_PROPERTY_SET:
mpctx->opts->audio_delay = *(float *)arg;
- mpctx->delay += mpctx->opts->audio_delay - delay;
+ if (mpctx->ao_chain && mpctx->vo_chain)
+ mpctx->delay += mpctx->opts->audio_delay - delay;
return M_PROPERTY_OK;
}
return mp_property_generic_option(mpctx, prop, action, arg);
@@ -2441,7 +2442,7 @@ static int mp_property_video_color(void *ctx, struct m_property *prop,
const char *name = prop->priv ? prop->priv : prop->name;
MPContext *mpctx = ctx;
if (!mpctx->vo_chain)
- return M_PROPERTY_UNAVAILABLE;
+ return mp_property_generic_option(mpctx, prop, action, arg);
switch (action) {
case M_PROPERTY_SET: {
@@ -2922,8 +2923,6 @@ static int mp_property_sub_delay(void *ctx, struct m_property *prop,
{
MPContext *mpctx = ctx;
struct MPOpts *opts = mpctx->opts;
- if (!mpctx->video_out)
- return M_PROPERTY_UNAVAILABLE;
switch (action) {
case M_PROPERTY_PRINT:
*(char **)arg = format_delay(opts->sub_delay);
@@ -2937,8 +2936,6 @@ static int mp_property_sub_pos(void *ctx, struct m_property *prop,
{
MPContext *mpctx = ctx;
struct MPOpts *opts = mpctx->opts;
- if (!mpctx->video_out)
- return M_PROPERTY_UNAVAILABLE;
if (action == M_PROPERTY_PRINT) {
*(char **)arg = talloc_asprintf(NULL, "%d/100", opts->sub_pos);
return M_PROPERTY_OK;
diff --git a/player/video.c b/player/video.c
index 1ceda1f999..69f3d8cc9e 100644
--- a/player/video.c
+++ b/player/video.c
@@ -962,15 +962,15 @@ static void init_vo(struct MPContext *mpctx)
struct MPOpts *opts = mpctx->opts;
struct vo_chain *vo_c = mpctx->vo_chain;
- if (opts->gamma_gamma != 1000)
+ if (opts->gamma_gamma != 0)
video_set_colors(vo_c, "gamma", opts->gamma_gamma);
- if (opts->gamma_brightness != 1000)
+ if (opts->gamma_brightness != 0)
video_set_colors(vo_c, "brightness", opts->gamma_brightness);
- if (opts->gamma_contrast != 1000)
+ if (opts->gamma_contrast != 0)
video_set_colors(vo_c, "contrast", opts->gamma_contrast);
- if (opts->gamma_saturation != 1000)
+ if (opts->gamma_saturation != 0)
video_set_colors(vo_c, "saturation", opts->gamma_saturation);
- if (opts->gamma_hue != 1000)
+ if (opts->gamma_hue != 0)
video_set_colors(vo_c, "hue", opts->gamma_hue);
video_set_colors(vo_c, "output-levels", opts->video_output_levels);