Commit Graph

36 Commits

Author SHA1 Message Date
wm4 314a4a572b command: disable edition switching if there are no editions
Commit 8d965a1bfb changed option/property min/max handling. As a
consequence, ranges that contain only 1 or 0 elements are not possible
anymore. Normally that's fine, because it makes no sense to have an
option that has only one or none allowed value (statically).

But edition switching used some sort of mechanism where the property can
return a different, dynamically decided range at runtime. That meant
that if there were <2 editions, edition switching with the "cycle"
command would always pick the same value. But with the recent commit,
this changed to having "no range set" and would cycle through all
integer values.

Work this around with a simple change. Now, edition switching on a file
without editions shows "edition: auto" instead of "edition: 0", which
may appear odd. But the former is the --edition default value, and
previous mpv versions rendered the edition property like this when not
using switching.

(Who the fuck uses editions?)
2020-03-14 01:32:27 +01:00
wm4 8ed76d2561 command: move property multiply code to m_property.c
I think this will help with reducing code duplication (see following
commit). The error messages loses the multiplication factor, but the
error message will be replaced by a generic one in the following commit
anyway.
2018-03-26 19:47:08 +02:00
wm4 2cded0ea9f m_property: change license to LGPL
All involved authors have agreed.
2017-06-12 17:00:20 +02:00
wm4 08432fcbd1 command: fix "cycle"/"add" not working on most properties
Oops, this is kind of important, isn't it?

Stopped working for properties which don't implement
M_PROPERTY_GET_CONSTRICTED_TYPE directly, as do_action() goes to the
property directly, while m_property_do() does a fallback.
2016-09-18 17:55:27 +02:00
wm4 2415b69572 player: more option/property consistency fixes
Some properties had a different type from their equivalent options (such
as mute, volume, deinterlace, edition). This wasn't really sane, as raw
option values should be always within their bounds. On the other hand,
these properties use a different type to reflect runtime limits (such as
range of available editions), or simply to improve the "UI" (you don't
want to cycle throuhg the completely useless "auto" value when cycling
the "mute" property).

Handle this by making them always return the option type, but also
allowing them to provide a "constricted" type, which is used for UI
purposes. All M_PROPERTY_GET_CONSTRICTED_TYPE changes are related to
this.

One consequence is that you can set the volume property to arbitrary
high values just like with the --volume option, but using the "add"
command it still restricts it to the --volume-max range.

Also deprecate --chapter, as it is grossly incompatible to the chapter
property. We pondered renaming it to --chapters, or introducing a more
powerful --range option, but concluded that --start --end is actually
enough.

These changes appear to take care of the last gross property/option
incompatibilities, although there might still be a few lurking.
2016-09-18 16:08:21 +02:00
wm4 d32bee5f01 command: add options to property list
Now options are accessible through the property list as well, which
unifies them to a degree.

Not all options support runtime changes (meaning affected components
need to be restarted for the options to take effects). Remove from the
manpage those properties which are cleanly mapped to options anyway.
From the user-perspective they're just options available through the
property interface.
2016-09-01 20:00:43 +02:00
wm4 ce8dae3f0d m_property: remove pointless explicitly clamping
This is basically dead code, and even the commit that added this code 4
years ago said that this should be for debugging only.

(Though it is possible that the clamp callback was used for something
else, and then unused again. Also, some of the clamping code remains and
is used for internal checking, e.g. clamp_double().)
2016-08-31 15:31:51 +02:00
wm4 8e96e04999 command: fix cycling certain properties
Commit a9bd4535 generally changed properties are set to string values.
This actually broke the fallback for non-string properties, because the
set string action was redirected directly to the property, instead of
the generic handler and its fallback code.
2016-04-15 22:10:19 +02:00
wm4 a9bd4535d2 client API: improve mpv_set_property() handling of MPV_FORMAT_NODE
If a mpv_node wrapped a string, the behavior was different from calling
mpv_set_property() with MPV_FORMAT_STRING directly. Change this.

The original intention was to be strict about types if MPV_FORMAT_NODE
is used. But I think the result was less than ideal, and the same change
towards less strict behavior was made to mpv_set_option() ages ago.
2016-04-15 11:32:40 +02:00
Dmitrij D. Czarkoff ea442fa047 mpv_talloc.h: rename from talloc.h
This change helps avoiding conflict with talloc.h from libtalloc.
2016-01-11 21:05:55 +01:00
wm4 9693e0f57a Remove some VLAs
They are evil and should be eradicated. Some of these were pretty dumb
anyway.

There are probably some more around in platform specific code or other
code not enabled by default on Linux.
2015-11-06 21:12:20 +01:00
wm4 1eaceb5fae command: remove old property deprecation warning mechanism
We don't need two.

This mechanism was basically for MPlayer, and it has expired its
usefulness by now.
2015-05-22 20:08:04 +02:00
Marcin Kurczewski f43017bfe9 Update license headers
Signed-off-by: wm4 <wm4@nowhere>
2015-04-13 12:10:01 +02:00
wm4 ab37a77b36 m_property: memcpy(ptr, NULL, 0) is undefined 2015-03-23 18:02:28 +01:00
wm4 2c22fcd350 options: fix parsing for options/af and options/vf
Basically, the declared option name and the name passed to the
parse_obj_settings_list() must be the same.

Fixes the issue addressed in #1550, but differently.
2015-02-03 13:40:55 +01:00
wm4 75f38dcc9a m_property: fix a typo
The wrong value was checked for an error. Oops.

Found by Coverity.
2014-11-21 10:09:38 +01:00
wm4 13033ce2c4 command: make sub-properties more flexible
This makes it work with all kind of types, instead of just some simple
ones.
2014-11-13 17:26:22 +01:00
wm4 dbf59abe05 command: fix weird stuff
Happens to fix some aspects of some properties (especially reading
"option-flags/x" as native value).
2014-11-13 17:25:04 +01:00
wm4 0aaf688c2d command: make m_property_strdup_ro with NULL mean unavailable
This catches a few cases which basically call:

    m_property_strdup_ro(..., ..., NULL)

which would return NULL strings. This should generally be avoided
(although it's allowed due to reasons), and it seems most callers
actually intend this to mean M_PROPERTY_UNAVAILABLE.
2014-09-01 21:50:54 +02:00
wm4 e00aad18cb command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)

This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:

   int (*)(const m_option_t*, int, void*, void*)

but the actual function signatures were:

   int (*)(m_option_t*, int, void*, MPContext *)

Two arguments were mismatched.

This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 02:11:39 +02:00
wm4 333c8cbc29 command: remove extended information from --list-properties
This used to display the property type, but it was not always correct or
even available. The way the property mechanism works, we can know this
only at runtime.
2014-04-11 01:27:57 +02:00
wm4 01f3e46290 command: fix access to "metadata/list" property
The function tag_property() in command.c passed a key action with empty
path to m_property_read_list. This is normally not valid, because key
actions are supposed to access sub-paths. But it's kind of inconvenient
to check for this case in tag_property(). So make it valid by providing
a m_property_unkey() function, which turns a key access to "" into a
top-level action.
2014-03-30 13:50:23 +02:00
wm4 5cd20c7320 command: add helper function to split property paths
We've just checked whether a sub-path started with "name/", but that
changes behavior whether the property name has a trailing '/' or not.
Using a helper function to split of path components avoids this problem.
2014-03-30 13:41:03 +02:00
wm4 7cc985f3d0 m_property: don't parse empty string as 0
Nice strtol() usage error.
2014-03-30 13:29:56 +02:00
wm4 082b1cdeaa m_property: allow setting string properties via M_PROPERTY_SET_STRING
Setting string options to strings over the m_option fallback (i.e.
M_PROPERTY_SET_STRING is called if the option type is CONF_TYPE_STRING)
failed. This was because m_option_parse() returns 0. 0 still means
success, but the property code tried to be clever, and considered 0 not
a success in order to disallow setting flags to an emtpy string (which
in turn is allowed, because the command line allows flag options without
parameters).

Fix this by removing the overly clever code.

This could happen when e.g. using the "set" command on options/title (a
string option), and also was a problem for the client API.

Closes #610.
2014-03-03 12:48:41 +01:00
wm4 a0b1d5f888 m_property: fix confused error code
This broke the client API.
2014-02-26 21:03:35 +01:00
wm4 a6ebfbea69 m_property: retrieve chapter lists etc. as mpv_node
This automatically allows accessing properties like chapter-list and
track-list to be read as mpv_node. This affects all properties which use
m_property_read_sub() and m_property_read_list().
2014-02-24 22:50:23 +01:00
wm4 91f752f43f m_property: add mechanism to access properties as mpv_node
Allows retrieving properties by their native values (or something close
to it), rather than having to go through string conversion. The caller
could actually just copy the value itself and then use the m_option
functions to convert it to mpv_node, but maybe it's more flexible this
way.
2014-02-24 22:50:23 +01:00
wm4 b097d76281 m_property: simplify some code 2014-02-24 20:51:05 +01:00
wm4 f225b5fc00 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.
2014-02-23 16:49:47 +01:00
wm4 801de5ac6d m_property: add a mechanism to organize a list of sub-properties
This automatically adds a "count" sub-property, and for each entry in
the range [0, count), a numbered sub-property to access the item.
2014-02-16 03:51:02 +01:00
wm4 309ae76e0b m_property: add a sub-property mechanism
This adds a mechanism for easier export of sub-properties. The following
commits will make use of it to export fine grained information about
certain things. The sub-property mechanism reduces the amount of code
needed to export a data value to 1 line.
2014-02-16 03:51:02 +01:00
wm4 d8d42b44fc m_option, m_config: mp_msg conversions
Always pass around mp_log contexts in the option parser code. This of
course affects all users of this API as well.

In stream.c, pass a mp_null_log, because we can't do it properly yet.
This will be fixed later.
2013-12-21 21:05:02 +01:00
wm4 a2d144fc8f m_property: mp_msg conversions
Includes some semi-crappy hacks to avoid changing too much code for this
conversion (allowing NULL log argument for m_property_do()).
2013-12-21 21:04:21 +01:00
wm4 0112143fda Split mpvcore/ into common/, misc/, bstr/ 2013-12-17 02:39:45 +01:00
wm4 eb15151705 Move options/config related files from mpvcore/ to options/
Since m_option.h and options.h are extremely often included, a lot of
files have to be changed.

Moving path.c/h to options/ is a bit questionable, but since this is
mainly about access to config files (which are also handled in
options/), it's probably ok.
2013-12-17 02:07:57 +01:00