summaryrefslogtreecommitdiffstats
path: root/options/m_property.c
Commit message (Collapse)AuthorAgeFilesLines
* m_property: add `>` for fixed precision floating-point expansionKacper Michajłow2024-03-211-2/+5
| | | | | | | | | | | | | | This enhancement makes it easier to create constant width property expansions, useful for the `--term-status-msg`. Additionally, it changes to `%f` printing with manual zero trimming, which is easier to control than `%g`. With this method, we can directly specify precision, not just significant numbers. This approach also avoids overly high precision for values less than 1, which is not necessary for a generic floating-point print function. A new print helper function is added, which can be used with adjusted precision for specific cases where a different default is needed. This also unifies the code slightly.
* m_option: initialize m_option_value union properlyKacper Michajłow2023-10-231-3/+3
| | | | | | | | | C standard says that `= {0}` activates and initializes first member of union. We expect whole union to be zeroed, it is used as default value. Initialize union with one zeroed default instance to ensure proper init. Fixes: #12711
* m_property: add read_sub_validate to check if should be processedKacper Michajłow2023-10-141-0/+17
| | | | | In many cases it makes sense to early exit instead of preparing all the data only to return type or not implemented.
* options: change parameter that was forgottin in property transitionChristoph Heinrich2023-02-271-2/+2
| | | | | 17d91b9d4d2d208f4a847395198cdbbcad18de93 changed the name, but not the parameter type and cast
* options: transition properties from flag to boolChristoph Heinrich2023-02-211-2/+2
|
* various: drop unused #include "config.h"Thomas Weißschuh2023-02-201-2/+0
| | | | | | Most sources don't need config.h. The inclusion only leads to lots of unneeded recompilation if the configuration is changed.
* m_property: avoid using a small stack buffer in m_property_do_bstrrcombs2023-02-131-5/+4
| | | | This allows operations on properties with longer names (e.g. deeply-nested user-data sub-props).
* command: disable edition switching if there are no editionswm42020-03-141-1/+2
| | | | | | | | | | | | | | | | | | | | | | Commit 8d965a1bfb3 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?)
* command: move property multiply code to m_property.cwm42018-03-261-0/+29
| | | | | | | 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.
* m_property: change license to LGPLwm42017-06-121-7/+7
| | | | All involved authors have agreed.
* command: fix "cycle"/"add" not working on most propertieswm42016-09-181-1/+2
| | | | | | | | 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.
* player: more option/property consistency fixeswm42016-09-181-0/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* command: add options to property listwm42016-09-011-2/+2
| | | | | | | | | | | 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.
* m_property: remove pointless explicitly clampingwm42016-08-311-9/+0
| | | | | | | | | 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().)
* command: fix cycling certain propertieswm42016-04-151-1/+1
| | | | | | | 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.
* client API: improve mpv_set_property() handling of MPV_FORMAT_NODEwm42016-04-151-12/+5
| | | | | | | | | 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.
* mpv_talloc.h: rename from talloc.hDmitrij D. Czarkoff2016-01-111-1/+1
| | | | This change helps avoiding conflict with talloc.h from libtalloc.
* Remove some VLAswm42015-11-061-6/+4
| | | | | | | | 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.
* command: remove old property deprecation warning mechanismwm42015-05-221-48/+1
| | | | | | | We don't need two. This mechanism was basically for MPlayer, and it has expired its usefulness by now.
* Update license headersMarcin Kurczewski2015-04-131-5/+4
| | | | Signed-off-by: wm4 <wm4@nowhere>
* m_property: memcpy(ptr, NULL, 0) is undefinedwm42015-03-231-1/+2
|
* options: fix parsing for options/af and options/vfwm42015-02-031-1/+4
| | | | | | | 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.
* m_property: fix a typowm42014-11-211-1/+1
| | | | | | The wrong value was checked for an error. Oops. Found by Coverity.
* command: make sub-properties more flexiblewm42014-11-131-9/+7
| | | | | This makes it work with all kind of types, instead of just some simple ones.
* command: fix weird stuffwm42014-11-131-0/+1
| | | | | Happens to fix some aspects of some properties (especially reading "option-flags/x" as native value).
* command: make m_property_strdup_ro with NULL mean unavailablewm42014-09-011-0/+2
| | | | | | | | | | 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.
* command: redo the property typewm42014-06-131-42/+66
| | | | | | | | | | | | | | | | | | | | | | | 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.
* command: remove extended information from --list-propertieswm42014-04-111-19/+4
| | | | | | 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.
* command: fix access to "metadata/list" propertywm42014-03-301-0/+14
| | | | | | | | | 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.
* command: add helper function to split property pathswm42014-03-301-0/+14
| | | | | | 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.
* m_property: don't parse empty string as 0wm42014-03-301-1/+2
| | | | Nice strtol() usage error.
* m_property: allow setting string properties via M_PROPERTY_SET_STRINGwm42014-03-031-2/+1
| | | | | | | | | | | | | | | | | 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.
* m_property: fix confused error codewm42014-02-261-1/+1
| | | | This broke the client API.
* m_property: retrieve chapter lists etc. as mpv_nodewm42014-02-241-4/+54
| | | | | | 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().
* m_property: add mechanism to access properties as mpv_nodewm42014-02-241-0/+36
| | | | | | | | 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.
* m_property: simplify some codewm42014-02-241-10/+6
|
* command: don't use option name in propertieswm42014-02-231-15/+5
| | | | | | | | | | | | | 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.
* m_property: add a mechanism to organize a list of sub-propertieswm42014-02-161-0/+77
| | | | | This automatically adds a "count" sub-property, and for each entry in the range [0, count), a numbered sub-property to access the item.
* m_property: add a sub-property mechanismwm42014-02-161-0/+61
| | | | | | | 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.
* m_option, m_config: mp_msg conversionswm42013-12-211-1/+1
| | | | | | | | 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.
* m_property: mp_msg conversionswm42013-12-211-17/+23
| | | | | Includes some semi-crappy hacks to avoid changing too much code for this conversion (allowing NULL log argument for m_property_do()).
* Split mpvcore/ into common/, misc/, bstr/wm42013-12-171-2/+2
|
* Move options/config related files from mpvcore/ to options/wm42013-12-171-0/+382
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.