summaryrefslogtreecommitdiffstats
path: root/m_property.h
Commit message (Collapse)AuthorAgeFilesLines
* command: reduce some property boilerplatewm42012-10-141-0/+5
| | | | | | | | | | Reduces code needed for implementing string and int64_t read-only properties. Originally, there actually was a m_property_string_ro(), but it was removed, as that would have implicitly strdup'ed the string. But the new name m_property_strdup_ro() should make it quite clear what is happening.
* commands: don't use dummy option declaration for propertieswm42012-10-121-0/+2
| | | | | | | | | | | | | | | | | | | | The property-to-option bridge (when properties change values normally set by the command line parser) uses M_PROPERTY_GET_TYPE to get the exact option type. In these cases, the entry in mp_properties[] is unused, except for the name field and the property callback. Instead, mp_property_generic_option() implements M_PROPERTY_GET_TYPE and returns the m_option as defined in cfg-mplayer.h. However, if a property is unavailable, mp_property_generic_option() is never actually called, and M_PROPERTY_GET_TYPE will return the dummy option entry. We could make sure that the dummy option entry equals the option entry defined in cfg-mplayer.h. But this would duplicate all information. Add a dummy option type m_option_type_dummy, which is used by entries using the property-to-option bridge. Make M_PROPERTY_GET_TYPE fail if this type is encountered. This dummy should never be used, as it isn
* commands: change property expansion format stringwm42012-10-121-6/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This affects property format strings like they are used in the "show_text" input command, for --playing-msg, and other places. To quote the documentation comment on m_properties_expand_string(): ${NAME} is expanded to the value of property NAME. If NAME starts with '=', use the raw value of the property. ${NAME:STR} expands to the property, or STR if the property is not available. ${?NAME:STR} expands to STR if the property is available. ${!NAME:STR} expands to STR if the property is not available. STR is recursively expanded using the same rules. "$$" can be used to escape "$", and "$}" to escape "}". "$>" disables parsing of "$" for the rest of the string. Most importantly, "?(property:str)" becomes "${?property:str}". Make the simple fallback case easier, e.g. "${property:fallback}" instead of "${property}?(!property:fallback)". Add the ability to escape the format meta characters. "$" is used for escaping, because escaping with "\" is taken by the commands parser in the layer below. "$>" can be used to disable interpretation of format strings (of course escapes by the commands parser can't be canceled). By default, properties which are unavailable or don't exist are turned into a string signaling the status (e.g. "(unavailable)"), instead of an empty string. If an empty string is desired, this has to be done explicitly: "${property:}" (the fallback part is an empty string). Raw properties still return an empty string on error. m_properties_expand_string() now returns a talloc'ed pointer, instead of a malloc'ed one.
* commands: cosmetics: rename thingswm42012-10-121-7/+7
| | | | | | | | | This is Better (tm). The only actual change is that with M_PROPERTY_SET_STRING, the option parser will use the property name, instead whatever was set in the name field of the option returned by M_PROPERTY_GET_TYPE. In most cases, these should be the same, though.
* commands: replace "switch" with "add" and "cycle"wm42012-10-121-8/+12
| | | | | | | | | | | | | | Now it depends on the command whether a property wraps around, or stops at min/max valid property value. For practically all properties, it's quite unambiguous what the "switch" command should have done, and there's technically no need to replace it with these new commands. More over, most properties that cycle are boolean anyway. But it seems more orthogonal to make the difference explicit, rather than hardcoding it. Having different commands also makes it more explicit to the user what these commands do, both just due to the naming, and what wrapping policy is used. The code is simpler too.
* commands: remove M_PROPERTY_SWITCH from edition propertywm42012-10-121-0/+4
| | | | | | Instead, communicate the new value range with M_PROPERTY_GET_TYPE. Add M_PROPERTY_GET_WRAP to allow properties to enable cycling instead of stopping at min/max.
* commands: make M_PROPERTY_GET_TYPE return an option copywm42012-10-121-1/+1
| | | | | Change the type of the arg for this action from m_option** to m_option*. This makes it easier to change some aspects of the option dynamically.
* commands: cosmetic changes mostly to m_property.hwm42012-10-121-120/+76
| | | | | | | | | The Doxygen-style documentation comments were nothing but bloat. Also move mp_property_do() and mp_property_print() to command.h, where they should belong, and fix their argument types. m_property.c/h is supposed to be generic, while command.h provides declarations specific to the mplayer core.
* commands: add more property-option bridge uses, rename some optionswm42012-10-121-36/+5
| | | | | | | | | | | | | Make more properties use the property-to-option bridge to reduce code size and to enforce consistency. Some options are renamed to the same as the properties (the property names are better in all cases). Do some other minor cleanups. One bigger issue was memory management of strings: M_PROPERTY_TO_STRING assumed the strings were statically allocated, and no dynamic allocations could be returned. Fix this in case the need for such properties arises in the future. Get rid of m_property_string_ro(), because it's not always clear that the "action" parameter is M_PROPERTY_SET and the string argument will be used.
* commands: handle property clamping in m_optionwm42012-10-121-8/+0
| | | | | | | | | | | | | | | Instead of clamping property values to the valid range in each property implementation, handle it in the property layer. The functionality to handle clamping for each type is in m_option.c. It's not really clear whether this is really needed. Normally, the raw values for M_PROPERTY_SET come only from m_option_type.parse (setting properties as string) or from m_option_parse.add (using the "switch" input command). However, since this was already done before, and since we _really_ want to be sure only to write valid values, add this code anyway. The newly added warnings/error messages should never actually be printed during normal operation and are for debugging (if they happen, we definitely want to see them).
* commands: generally handle property formatting with m_optionwm42012-10-121-11/+0
| | | | | | | | | | | | | Use the m_option code by default to format property values, instead of having separate code in m_property. To facilitate that, add a pretty_print callback to option types. These format values in a more human readable and user friendly way, as opposed to the print callback, which produces parseable values. This also changes the strings used with flags. Instead of "enabled" and "disabled", flags are formatted as "yes" and "no". (We could use the pretty_print callback to deal with this, but we don't for consistency.)
* commands: handle property stepping in a generic waywm42012-10-121-12/+4
| | | | | | | | | | | | | | | | | | | | | Instead of forcing each property implementation implement its own logic for M_PROPERTY_STEP_UP/M_PROPERTY_STEP_DOWN, handle it in the generic property code. Rename the M_PROPERTY_STEP_UP command to M_PROPERTY_SWITCH (the other property command, M_PROPERTY_STEP_DOWN, isn't needed anymore: stepping downwards is done by passing a negative argument). Always use double as argument type; it makes the code easier, and covers all property types. Move the code which does the actual type-specific value stepping to m_option.c (the idea is that m_option handles types). Some properties still have custom handlers implemented with M_PROPERTY_SWITCH. They can't be mapped to the generic mechanism, because their value range is dynamic or entirely unknown. For some properties, the default step stride is changed to 1. This is no issue, because the default bindings in input.conf all use an explicit stride in the affected cases.
* commands: rename "osdlevel" option and property, make it a choicewm42012-10-121-4/+0
| | | | | | | | | Rename both the option and property to "osd-level", which fits a bit better with the general naming scheme. Make it a choice instead of an integer range. I failed to come up with good names for the various levels, so leave them as-is. Remove the useless property handler for the "loop" property too.
* Add license header to all top-level files missing them.diego2010-01-301-0/+18
| | | | git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@30471 b3059339-0415-0410-9bf9-f77b7e298cf2
* whitespace cosmetics: Remove all trailing whitespace.diego2009-05-131-1/+1
| | | | git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@29305 b3059339-0415-0410-9bf9-f77b7e298cf2
* Add a m_property_flag_ro function for the default behaviour of areimar2008-10-011-0/+3
| | | | | | read-only flag. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@27679 b3059339-0415-0410-9bf9-f77b7e298cf2
* Add necessary #includes to pass 'make checkheaders'.diego2008-03-041-0/+2
| | | | git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@26163 b3059339-0415-0410-9bf9-f77b7e298cf2
* Add MPLAYER_ prefix to multiple inclusion guards.diego2008-02-221-3/+3
| | | | git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@26061 b3059339-0415-0410-9bf9-f77b7e298cf2
* All the m_property stuff works fine with constant m_option_treimar2008-01-131-15/+15
| | | | git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@25744 b3059339-0415-0410-9bf9-f77b7e298cf2
* Add multiple inclusion guards to all header files that lack them.diego2008-01-011-0/+4
| | | | git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@25581 b3059339-0415-0410-9bf9-f77b7e298cf2
* Move the time printing code out of the length property.albeu2007-05-311-0/+4
| | | | git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@23434 b3059339-0415-0410-9bf9-f77b7e298cf2
* Make all the info available via the metadata API available via properties.albeu2007-05-291-0/+3
| | | | git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@23412 b3059339-0415-0410-9bf9-f77b7e298cf2
* Rework the property API to allow sub properties such asalbeu2007-05-291-18/+33
| | | | | | | metadata/title, etc. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@23411 b3059339-0415-0410-9bf9-f77b7e298cf2
* Split command/property handling from mplayer.c to a new file command.c.uau2007-02-211-6/+6
| | | | | | | | | Move some global and static variables under a struct that can be given as a parameter. Add a context argument to the property functions so that they do not have to depend on global/static variables. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@22298 b3059339-0415-0410-9bf9-f77b7e298cf2
* marks several read-only string parameters which aren't modified inside the ↵reynaldo2006-07-151-1/+1
| | | | | | called function as const. Patch by Stefan Huehner, stefan AT huehner-org git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@19109 b3059339-0415-0410-9bf9-f77b7e298cf2
* marks several string parameters as const, as they are not modified inside ↵reynaldo2006-07-131-1/+1
| | | | | | the function, Patch by Stefan Huehner, stefan AT huehner-org git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@19058 b3059339-0415-0410-9bf9-f77b7e298cf2
* Fix most of the mistakes pointed out by Diego.albeu2006-04-251-3/+3
| | | | git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@18284 b3059339-0415-0410-9bf9-f77b7e298cf2
* Doxygen attack!albeu2006-04-241-29/+119
| | | | git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@18259 b3059339-0415-0410-9bf9-f77b7e298cf2
* Add the declarations for mp_property_find/do.albeu2006-04-221-0/+8
| | | | git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@18190 b3059339-0415-0410-9bf9-f77b7e298cf2
* Add an option to list the properties: -list-propertiesalbeu2006-03-221-0/+2
| | | | git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@17915 b3059339-0415-0410-9bf9-f77b7e298cf2
* Add the new property API and implement a couple properties.albeu2006-03-221-0/+78
Move the volume and mute command to the command to property bridge. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@17912 b3059339-0415-0410-9bf9-f77b7e298cf2