summaryrefslogtreecommitdiffstats
path: root/m_option.h
Commit message (Collapse)AuthorAgeFilesLines
* Rename directories, move files (step 1 of 2) (does not compile)wm42012-11-121-519/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Tis drops the silly lib prefixes, and attempts to organize the tree in a more logical way. Make the top-level directory less cluttered as well. Renames the following directories: libaf -> audio/filter libao2 -> audio/out libvo -> video/out libmpdemux -> demux Split libmpcodecs: vf* -> video/filter vd*, dec_video.* -> video/decode mp_image*, img_format*, ... -> video/ ad*, dec_audio.* -> audio/decode libaf/format.* is moved to audio/ - this is similar to how mp_image.* is located in video/. Move most top-level .c/.h files to core. (talloc.c/.h is left on top- level, because it's external.) Park some of the more annoying files in compat/. Some of these are relicts from the time mplayer used ffmpeg internals. sub/ is not split, because it's too much of a mess (subtitle code is mixed with OSD display and rendering). Maybe the organization of core is not ideal: it mixes playback core (like mplayer.c) and utility helpers (like bstr.c/h). Should the need arise, the playback core will be moved somewhere else, while core contains all helper and common code.
* cleanup: remove M_OPT_NOCMDwm42012-10-301-4/+0
| | | | Unused.
* Merge branch 'input_changes' into masterwm42012-10-121-10/+29
|\ | | | | | | | | | | | | | | Conflicts: DOCS/man/en/vo.rst etc/input.conf input/input.c m_property.c
| * m_option.h: separate creating choices array into M_CHOICES macrowm42012-10-121-2/+3
| | | | | | | | Reduces code duplication, increases reusability.
| * commands: don't replicate mapping to option in levels_property_helperwm42012-10-121-6/+0
| | | | | | | | | | | | | | | | This should be done by mp_property_generic_option() only. Also reindent levels_property_helper() to make it a little bit more readable. Remove the m_option_get_ptr() function, which doesn't really make sense anymore.
| * commands: handle property clamping in m_optionwm42012-10-121-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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).
| * options: simplify somewhat by introducing a union for option valueswm42012-10-121-0/+19
| | | | | | | | | | | | | | | | The m_option_value union is supposed to contain a field for each possible option type (as long as it actually stores data). This helps avoiding silly temporary memory alocations. Using a pointer to an union and to a field of the union interchangeably should be allowed by standard C.
| * options: accept "yes" and "no" only for flagswm42012-10-121-1/+1
| | | | | | | | | | | | | | | | | | | | This removes the alternative values like "off", "0", "false" etc., and also the non-English versions of these. This is done for general consistency. It's better to have a single way of doing things when multiple ways don't add singificant value. Also update some choices for consistency.
| * commands: generally handle property formatting with m_optionwm42012-10-121-0/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | 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-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
| * options: remove CONF_TYPE_POSITIONwm42012-10-121-2/+0
| | | | | | | | | | | | | | | | | | This was the option parser for the off_t C type. These days, off_t is always int64_t, so replace all its uses by int64_t and CONF_TYPE_INT64. Fix the --sstep option. It used CONF_TYPE_INT with an off_t variable, which will result in invalid memory accesses. Make it use type double instead, which seems to make more sense for this option.
* | options: simplify somewhat by introducing a union for option valueswm42012-09-231-0/+19
| | | | | | | | | | | | | | | | The m_option_value union is supposed to contain a field for each possible option type (as long as it actually stores data). This helps avoiding silly temporary memory alocations. Using a pointer to an union and to a field of the union interchangeably should be allowed by standard C.
* | options: accept "yes" and "no" only for flagswm42012-09-231-1/+1
| | | | | | | | | | | | | | | | | | | | This removes the alternative values like "off", "0", "false" etc., and also the non-English versions of these. This is done for general consistency. It's better to have a single way of doing things when multiple ways don't add singificant value. Also update some choices for consistency.
* | options: make cache option always per-filewm42012-09-231-5/+6
|/ | | | | | | | | | | When playing a network stream, the cache is automatically enabled. We don't want the cache to stay enabled when playback ends. (For example, the next file to be played could be a local file, and even if that is relatively contrieved, we want to do the right thing.) Introduced the flag M_OPT_LOCAL to force an option to be always file local. This allows enabling the old mplayer semantics on a per option basis.
* options: change --vid, --aid, --sid optionswm42012-09-181-0/+2
| | | | | | | | | | | | The --vid, --aid, --sid options now accept the values 'off' and 'auto', instead of having the user deal with the numeric values -2 and -1. The numeric values are not allowed anymore. Remove the --audio option. It was probably meant as compensation option for --no-audio. There are no such options for sub/video, and it was not documented, so just remove it. The replacement is "--aid=auto". Also do some updates to the manpage.
* options: change --loop option, and extend choice option typewm42012-09-181-0/+4
| | | | | | | | | | | | | | | | | | | | | | The --loop option takes slightly different parameters now. --loop=0 used to mean looping forever. Now it means looping is disabled (this is more logical: 2 means playing 2 more times, 1 means playing 1 more time, and 0 should mean playing not again). Now --loop=inf must be used to enable looping forever. Extend choice types to allow an optional range of integers as values. If CONF_RANGE is added to the flags of a m_option_type_choice option, m_option.min/max specify a range of allowed integer values. This can be used to remove "special" values from make integer range options. These special values are unintuitive, and sometimes expose mplayer internals to the user. The (internal) choice values can be freely mixed with the specified integer value range. If there are overlaps, the choice values are preferred for conversion to/from strings. Also make sure the extension to choice options works with properties. Add the ability to step choice properties downwards, instead of just upwards.
* options: remove M_OPT_IMPLICIT_DEFAULTwm42012-09-181-5/+0
| | | | | | | | | This was to make an option without value use the option's default value (e.g. --term-osd is the same as --term-osd=auto). Make it simpler by handling this case as an empty choice. The flag was probably needed when option handling still did ambiguous argument parsing.
* m_config: support auto-allocated sub-structswm42012-08-061-0/+17
| | | | | | | | | | | | | | Given your option struct has a field that is a pointer to another struct, this commit allows you to declare options that write into that other struct. The code in m_config will dereference the pointer field on its own if such an option is accessed. If the field is NULL on initialization of the containing m_config, the struct is automatically allocated. OPT_SUBSTRUCT() can be used to declare such a field. struct m_sub_options is used to describe the pointed-to struct, and includes size and defaults if the struct has to be allocated by m_config.
* m_config: support flatten and merge flags for suboptionswm42012-08-061-0/+8
| | | | | | | | | | | | | | | | | | M_OPT_PREFIXED allows adding top-level options with the suboption mechanism. The point of this is that, even though these options are top-level options, they don't need to be added directly to a top- level option array (such as mplayer_opts[]). Instead, the suboption can be defined in a separate source file. Only a suboption declaration is needed to add these options. M_OPT_MERGE is similar to M_OPT_PREFIXED, but doesn't add the name of the suboptions entry as prefix. Given you have a suboption declaration "prefix" and the suboption "subopt", you can pass them as follows on the command line: normal: --prefix=subopt=value M_OPT_PREFIXED: --prefix-subopt=value M_OPT_MERGE: --subopt=value
* options: get rid of some compatibility stuffwm42012-08-061-6/+0
| | | | | | | | | Doesn't make sense because we broke/are going to break compatibility with everything anyway. Remove mechanism for warning the user against disabled options. Remove colorspace alternative option values.
* options: get rid of ambiguous option parsingwm42012-08-051-6/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Options parsing used to be ambiguous, as in the splitting into option and values pairs was ambiguous. Example: -option -something It wasn't clear whether -option actually takes an argument or not. The string "-something" could either be a separate option, or an argument to "-option". The code had to call the option specific parser function to resolve this. This made everything complicated and didn't even have a real use. There was only one case where this was actually used: string lists (m_option_type_string_list) and options based on it. That is because this option type actually turns a single option into a proxy for several real arguments, e.g. "vf*" can handle "-vf-add" and "-vf-clr". Options suffixed with "-clr" are the only options of this group which take no arguments. This is ambiguous only with the "old syntax" (as shown above). The "new" option syntax always puts option name and value into same argument. (E.g. "--option=--something" or "--option" "--something".) Simplify the code by making it statically known whether an option takes a parameter or not with the flag M_OPT_TYPE_OLD_SYNTAX_NO_PARAM. If it's set, the option parser assumes the option takes no argument. The only real ambiguity left, string list options that end on "-clr", are special cased in the parser. Remove some duplication of the logic in the command line parser by moving all argument splitting logic into split_opt(). (It's arguable whether that can be considered code duplication, but now the code is a bit simpler anyway. This might be subjective.) Remove the "ambiguous" parameter from all option parsing related code. Make m_config unaware of the pre-parsing concept. Make most CONF_NOCFG options also CONF_GLOBAL (except those explicitly usable as per-file options.)
* options: remove CONF_TYPE_PRINT_INDIRECTwm42012-08-051-2/+0
| | | | This was unused.
* m_options: get rid of CONF_NOSAVEwm42012-08-041-8/+0
| | | | | | | This was already treated like CONF_GLOBAL. Profiles can actually be file-local, as long as the profile sets file local options only. Allow them to do so.
* options: revert passing around talloc contextswm42012-08-041-7/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit 48f0692ab9 "options: make option struct the talloc parent of options". This made things actually more complicated. It introduced a new parameter to the option parse and copy functions, which was used inconsistently. Some code passed a parent, some not. Morever, you have to call m_option_free() anyway, because not all options actually respect the talloc parent. There is also the question whether passing NULL as parent is supposed to work, or if you still have to implement m_config_free(). On the other hand, this simplifies nothing. I assume the intention was being able to free all option values with a single talloc_free() call, but the same goal can be reached by simply freeing the m_config struct. (The m_config talloc destructor will free each option values.) Get rid of the talloc parent context parameter. This essentially reverts commit 48f0692ab9 ("options: make option struct the talloc parent of options"). In video_out.c, make the VO priv struct the talloc parent for the m_config object, so that destroying the VO will free the options. The ability to free the m_config struct and all its managed options was introduced in commit 89a17bcda6c.
* options: remove "no" options variantswm42012-07-301-1/+1
| | | | | | | | | | | | | The old option parser required adding two options for each flag option: e.g. "-video" and "-novideo". Later, code was added to handle the "no-" prefix automatically for flag options. Remove the "no" prefixed options entirely (unless they are not flag options, then just rename them), and require the user to use the "no-" prefix instead. You can't use the old prefix anymore. Old: -novideo New: --no-video
* Merge remote-tracking branch 'origin/master'wm42012-07-281-19/+42
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: .gitignore bstr.c cfg-mplayer.h defaultopts.c libvo/video_out.c The conflict in bstr.c is due to uau adding a bstr_getline function in commit 2ba8b91a97e7e8. This function already existed in this branch. While uau's function is obviously derived from mine, it's incompatible. His function preserves line breaks, while mine strips them. Add a bstr_strip_linebreaks function, fix all other uses of bstr_getline, and pick uau's implementation. In .gitignore, change vo_gl3_shaders.h to use an absolute path additional to resolving the merge conflict.
| * options: make option struct the talloc parent of optionsUoti Urpala2012-07-161-4/+7
| | | | | | | | | | | | | | | | | | | | | | Allocate dynamically-allocated option values as talloc children of the option struct. This will allow implementing per-object (VO etc) options so that simply freeing the object will free associated options too. This doesn't change quite every allocation in m_option.c, but the exceptions are legacy types which will not matter for new per-object options.
| * options: support parsing values into substructsUoti Urpala2012-07-161-15/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add an alternate mode for option parser objects (struct m_config) which is not inherently tied to any particular instance of an option value struct. Instead, this type or parsers can be used to initialize defaults in or parse values into a struct given as a parameter. They do not have the save slot functionality used for main player configuration. The new functionality will be used to replace the separate subopt_helper.c parsing code that is currently used to parse per-object suboptions in VOs etc. Previously, option default values were handled by initializing them in external code before creating a parser. This initialization was done with constants even for dynamically-allocated types like strings. Because trying to free a pointer to a constant would cause a crash when trying to replace the default with another value, parser initialization code then replaced all the original defaults with dynamically-allocated copies. This replace-with-copy behavior is no longer supported for new-style options; instead the option definition itself may contain a default value (new OPTDEF macros), and the new function m_config_initialize() is used to set all options to their default values. Convert the existing initialized dynamically allocated options in main config (the string options --dumpfile, --term-osd-esc, --input=conf) to use this. Other non-dynamic ones could be later converted to use this style of initialization too. There's currently no public call to free all dynamically allocated options in a given option struct because I intend to use talloc functionality for that (make them children of the struct and free with it).
* | Merge remote-tracking branch 'origin/master'wm42012-05-201-69/+2
|\|
| * options: simplify option parsing/setting machineryUoti Urpala2012-05-081-69/+2
| | | | | | | | | | | | | | | | | | | | | | | | Each option type had three separate operations to copy option values between memory locations: copy between general memory locations ("copy"), copy from general memory to active configuration of the program ("set"), and in the other direction ("save"). No normal option depends on this distinction any more. Change everything to define and use a single "copy" operation only. Change the special options "include" and "profile", which depended on hacky option types, to be special-cased directly in option parsing instead. Remove the now unused option types m_option_type_func and m_option_type_func_param.
* | Merge remote-tracking branch 'origin/master' into my_masterwm42012-03-161-0/+1
|\| | | | | | | | | | | | | | | Conflicts: command.c mp_core.h mplayer.c screenshot.c
| * core: remove old EDL mode (--edl option)Uoti Urpala2012-03-091-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Remove the old EDL implementation that was activated with the --edl option. It is mostly redundant and inferior compared to the newer demux_edl support, though currently there's no support for using the same EDL files with the new implementation and the mute functionality of the old implementation is not supported. The main reason to remove the old implementation at this point is that the mute functionality would conflict with following audio volume handling changes, and working on the old code would be a wasted effort in the long run as at some point it would be removed anyway. The --edlout functionality is kept for now, even though after this commit there is no code that could directly read its output.
* | options: allow choice options without parameterwm42012-01-181-0/+5
|/ | | | | | | | | | | If an m_option_type_choice option is declared with M_OPT_IMPLICIT_DEFAULT in its flags, it doesn't require a parameter. For example, if --opt is such an option, it can be invoked as "--opt=val", "-opt", or "--opt". The last two will set the option to the first choice the option declares. Note that "-opt val" (using the old option syntax) is not allowed in this case, as it would be ambiguous. Normal option parsing should be unaffected.
* options: add "disabled option" functionalityUoti Urpala2011-09-041-0/+5
| | | | | | | | | | | Add functionality to mark options that depend on features disabled at compile time as disabled rather than not compiling the option definitions at all. This allows printing a warning about the option not being available because of a disabled feature, instead of just "unknown option". Because the option definitions are still compiled fully, this only works for definitions that do not reference symbols which are not available if the feature is disabled. Use the new functionality for options depending on libass.
* options: commandline: print error type for parse failuresUoti Urpala2011-07-291-0/+2
| | | | | | | | | | | | If parsing an option fails, print a string corresponding to the parse function return value (M_OPT_MISSING_PARAM etc). The primary motivation is that the parsing code already outputs messages explaining most problems, but does not itself print anything in the missing parameter case. Before double-dash --options such errors were rare (or rather they resulted in the next commandline argument being silently misinterpreted as an argument to the previous option instead); but now an argument like "--ss" should give a better indication about the problem than just "Error parsing option".
* core: improve --loop handlingUoti Urpala2011-07-291-0/+1
| | | | | | | | Make per-file loop option start from --ss position, not always 0. Do looping in more cases; before looping was only done when encountering real end of file, now it also happens for example at --endpos or --frames limits. Also move the --ss option to the option struct.
* options: change option parsing to use bstrUoti Urpala2011-07-291-14/+4
| | | | | | Using bstr allows simpler parsing code, especially because it avoids the need to modify or copy strings just to terminate extracted substrings.
* options: indicate ambiguous option parameters explicitlyUoti Urpala2011-07-291-17/+10
| | | | | | | | Command line options like "-foo xyz" are ambiguous: "xyz" may be a parameter to the option "foo" or an unrelated argument. Instead of relying on the struct m_config mode field (commandline/file) pass parameters to specify ambiguous mode explicitly. Meant for "--foo" options which are never ambiguous on command line either.
* cleanup: silence most of the clang warningsClément Bœsch2011-07-091-1/+1
|
* commands: change property mechanism to use talloc stringsUoti Urpala2011-07-031-1/+1
|</