summaryrefslogtreecommitdiffstats
path: root/m_config.c
Commit message (Collapse)AuthorAgeFilesLines
* m_config: support auto-allocated sub-structswm42012-08-061-37/+46
| | | | | | | | | | | | | | 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-14/+32
| | | | | | | | | | | | | | | | | | 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-31/+8
| | | | | | | | | 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-28/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.)
* m_config: always reject setting global options in per-file modewm42012-08-041-0/+6
| | | | | | | | | | Now the command line parser sets the m_config object into file local mode, so that m_config can check for this condition. Makes trying to set global options from a profile fail. Note: global options can be considered read-only by m_config, so maybe there should be an additional check for this. Reusing the file- local check is more practical for now, though.
* m_options: get rid of CONF_NOSAVEwm42012-08-041-3/+3
| | | | | | | 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.
* m_config: implement m_config_new in terms of m_config_simplewm42012-08-041-15/+11
| | | | | Also change m_config_simple() such that you need to register options using m_config_register_options().
* options: revert passing around talloc contextswm42012-08-041-10/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* m_config: reallow specifying static default values for string optionswm42012-08-021-1/+1
| | | | | | | | | | | | Commit dc2a4863af9b0e introduced a new way of specifying default values for strings (you're supposed to use OPTDEF_STR() instead of putting it into the option struct, such as it was done in defaultopts.c). The code to handle the old way was explicitly disabled, which caused random crashes when used. Allow the old way again. With the main option struct in particular, I see no reason why some option defaults should be specified in defaultopts.c, and some directly along the options.
* mplayer: turn playtree into a list, and change per-file option handlingwm42012-07-311-132/+93
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: - There is no playtree anymore. It's reduced to a simple list. - Options are now always global. You can still have per-file options, but these are optional and require special syntax. - The slave command pt_step has been removed, and playlist_next and playlist_prev added. (See etc/input.conf changes.) This is a user visible incompatible change, and will break slave-mode applications. - The pt_clear slave command is renamed to playlist_clear. - Playtree entries could have multiple files. This is not the case anymore, and playlist entries have always exactly one entry. Whenever something adds more than one file (like ASX playlists or dvd:// or dvdnav:// on the command line), all files are added as separate playlist entries. Note that some of the changes are quite deep and violent. Expect regressions. The playlist parsing code in particular is of low quality. I didn't try to improve it, and merely spent to least effort necessary to keep it somehow working. (Especially ASX playlist handling.) The playtree code was complicated and bloated. It was also barely used. Most users don't even know that mplayer manages the playlist as tree, or how to use it. The most obscure features was probably specifying a tree on command line (with '{' and '}' to create/close tree nodes). It filled the player code with complexity and confused users with weird slave commands like pt_up. Replace the playtree with a simple flat playlist. Playlist parsers that actually return trees are changed to append all files to the playlist pre-order. It used to be the responsibility of the playtree code to change per-file config options. Now this is done by the player core, and the playlist code is free of such details. Options are not per-file by default anymore. This was a very obscure and complicated feature that confused even experienced users. Consider the following command line: mplayer file1.mkv file2.mkv --no-audio file3.mkv This will disable the audio for file2.mkv only, because options are per-file by default. To make the option affect all files, you're supposed to put it before the first file. This is bad, because normally you don't need per-file options. They are very rarely needed, and the only reasonable use cases I can imagine are use of the encode backend (mplayer encode branch), or for debugging. The normal use case is made harder, and the feature is perceived as bug. Even worse, correct usage is hard to explain for users. Make all options global by default. The position of an option isn't significant anymore (except for options that compensate each other, consider --shuffle --no-shuffle). One other important change is that no options are reset anymore if a new file is started. If you change settings with slave mode commands, they will not be changed by playing a new file. (Exceptions include settings that are too file specific, like audio/subtitle stream selection.) There is still some need for per-file options. Debugging and encoding are use cases that profit from per-file options. Per-file profiles (as well as per-protocol and per-VO/AO options) need the implementation related mechanisms to backup and restore options when the playback file changes. Simplify the save-slot stuff, which is possible because there is no hierarchical play tree anymore. Now there's a simple backup field. Add a way to specify per-file options on command line. Example: mplayer f1.mkv -o0 --{ -o1 f2.mkv -o2 f3.mkv --} f4.mkv -o3 will have the following options per file set: f1.mkv, f4.mkv: -o0 -o3 f2.mkv, f3.mkv: -o0 -o3 -o1 -o2 The options --{ and --} start and end per-file options. All files inside the { } will be affected by the options equally (similar to how global options and multiple files are handled). When playback of a file starts, the per-file options are set according to the command line. When playback ends, the per-file options are restored to the values when playback started.
* bstr: rename bstr() function to bstr0(), and typedef bstr to struct bstrwm42012-07-281-7/+7
| | | | | Replace all uses of bstr() with bstr0(). Also remove the ridiculous C++ workaround.
* options: support "no-foo" syntax for flag suboptionsUoti Urpala2012-07-271-6/+23
| | | | | | | Allow using "no-foo" as an alternative to "foo=no" for flag suboptions, similarly to what top-level flag options already support. This means things like "--lavdopts=no-fast" or "--vo=vdpau:no-chroma-deint" are now supported.
* options: make option struct the talloc parent of optionsUoti Urpala2012-07-161-5/+8
| | | | | | | | | | | 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-47/+85
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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).
* options: simplify option parsing/setting machineryUoti Urpala2012-05-081-67/+49
| | | | | | | | | | | | 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.
* options: add "disabled option" functionalityUoti Urpala2011-09-041-12/+35
| | | | | | | | | | | 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: change option parsing to use bstrUoti Urpala2011-07-291-35/+40
| | | | | | 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-14/+19
| | | | | | | | 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.
* options: free option defaults when freeing configUoti Urpala2011-07-061-0/+5
| | | | | | | Possibly read-only default values of option variables are replaced with dynamically allocated defaults when registering options. Free these when freeing the overall config object on exit to clean up leak report results.
* options: allocate dynamic options with tallocUoti Urpala2011-07-061-3/+3
| | | | | | | | | Allocate data structures for dynamic option values with talloc. Hopefully there's no code left that tries to modify those dynamic option values outside the option parser and relies on them being malloc-allocated. Currently talloc functionality isn't used much and the allocations are not hierarchical, so the main practical use for now is just to allow very easy checking for memory leaks.
* cleanup: reformat and clean up m_config.[ch]Uoti Urpala2011-07-061-396/+409
| | | | | m_config.c changes include removal of "#ifdef MP_DEBUG" from around some assert lines.
* cleanup: remove more warningsClément Bœsch2011-05-021-3/+3
|
* options: remove CONF_OLD option flagUoti Urpala2011-01-311-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The resulting semantics of this flag are weird enough that they're unlikely to be what is wanted in any situation. Remove the flag and convert the two options using it, -screenw and -screenh, to use CONF_NOSAVE instead. I'm not sure why those specific options had the flag and if any flag is really needed, but I don't want to check in detail now and using CONF_NOSAVE should keep about the same behavior in practice. A bit more detail about the weird behavior this flag had: When not using file groups, the flag had the same behavior as CONF_NOSAVE, namely that when switching files the option would not be reset to the global value (only possible file-specific settings were applied). When using file groups, group-specific options would apply to the _first two_ files in the group, but for the rest after the first two, settings would not be reset when changing files (wtf?). This was a result of the following sequence: 1) push higher-level settings, enter group 2) apply group-specific settings 3) push settings before applying ones specific to file 1 in group 4) apply file 1 settings, play file 1 5) pop settings to return to group settings 6) push settings before applying ones specific to file 2 7) apply file 2 settings 8) pop settings Here the option was set at 2). 3) saved it because it had been set after last push, so 5) restored the setting and it was used for file 2 too. However 6) no longer saved it because there had been pushes after the original setting in 2), thus 8) no longer restored the setting and the option was no longer forced to any particular value when playing further files after that.
* commands: add generic option -> property wrapperUoti Urpala2010-12-181-2/+2
| | | | | | | | | Add mp_property_generic_option(), a property function that can be used for generic option-based properties that do not require any action beyond manipulating the value of the option variable. Currently it directly implements GET and SET, plus STEP_UP for "choice" options only. Use it to add a property for -pts-association-mode (not particularly useful in normal use, but serves as a test).
* options: fix autoloaded profile handling of flag optionsUoti Urpala2010-11-151-0/+3
| | | | | | | When loading automatically enabled profiles (like "[extension.avi]") flag options were handled as on the command line; for example "fs=no" was interpreted like "-fs" on command line, ignoring the "no" part. Fix the parsing to treat them the same as other config file entries.
* cleanup: don't check for NULL before free()diego2010-11-081-1/+1
| | | | | | patch by Clément Bœsch, ubitux gmail com git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@32598 b3059339-0415-0410-9bf9-f77b7e298cf2
* m_config.c: cosmetics: Move functions to avoid forward declarationsdiego2010-11-021-114/+108
| | | | git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@32387 b3059339-0415-0410-9bf9-f77b7e298cf2
* m_config.[ch]: mark some function parameters constdiego2010-11-021-6/+6
| | | | | | patch by Clément Bœsch, ubitux gmail com git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@32386 b3059339-0415-0410-9bf9-f77b7e298cf2
* Delete things related to old translation systemUoti Urpala2010-03-101-1/+0
| | | | | Remove the help/ subdirectory, configure code to create toplevel help_mp.h, and all the '#include "help_mp.h"' lines from .c files.
* Merge svn changes up to r30748Uoti Urpala2010-03-101-6/+6
|\
| * Make more option-parsing related function arguments const.reimar2010-02-251-4/+4
| | | | | | | | | | | | | | Prerequisite for making stream_open filename const in a proper way. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@30737 b3059339-0415-0410-9bf9-f77b7e298cf2
| * Mark m_config_get_option_ptr() as static, it is only used within the file.diego2010-02-201-1/+1
| | | | | | | | git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@30673 b3059339-0415-0410-9bf9-f77b7e298cf2
* | Merge svn changes up to r30475Uoti Urpala2010-03-091-0/+17
|\|
| * Add license header to all top-level files missing them.diego2010-01-301-0/+17
| | | | | | | | git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@30471 b3059339-0415-0410-9bf9-f77b7e298cf2
| * whitespace cosmetics: Remove all trailing whitespace.diego2009-05-131-13/+13
| | | | | | | | git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@29305 b3059339-0415-0410-9bf9-f77b7e298cf2
* | Restore collapsed whitespace in output messagesUoti Urpala2010-03-071-1/+1
| | | | | | | | | | | | | | | | | | For some reason commit e306174952d42e1cd6cc5efc50ae6bb0410501bc, which replaced translation macro names with the corresponding English strings, also collapsed multiple consecutive space characters into one. Change most of these back. In a couple of cases the amount of whitespace is important for alignment, and for the rest it at least keeps the strings closer to the existing translations.
* | Remove trailing whitespace from most filesUoti Urpala2009-07-071-10/+10
| |
* | Translation system changes part 2: replace macros by stringsAmar Takhar2009-07-071-14/+14
| | | | | | | | | | Replace all MSGTR_ macros in the source by the corresponding English string.
* | Translation system changes part 1: wrap translated stringsAmar Takhar2009-07-071-14/+14
| | | | | | | | | | Replace mp_msg() calls which have a translated string as the format argument with mp_tmsg and add _() around all other translated strings.
* | m_config.c: Remove unused function m_config_get_option_ptrUoti Urpala2008-08-121-14/+0
| |
* | options: Make dynamic dup hack work with new optionsUoti Urpala2008-04-301-4/+7
| | | | | | | | | | | | | | | | The option system has a hack that converts default values (potentially constants) of dynamically allocated options to allocated ones when the options are first added to the config system, so that all values can be equally freed later. Make this work with new-style options in the option struct too.
* | m_config.c: Cosmetics: fix nested block lacking indentationUoti Urpala2008-04-301-16/+17
| |
* | Mark some constant symbols as suchUoti Urpala2008-04-261-1/+1
| |
* | Move global mconfig to mpctxUoti Urpala2008-04-261-2/+9
| | | | | | | | | | | | | | | | | | | | | | The global was used in the function cfg_include which handles the -include option. Make the address available in that function by creating a new dynamically allocated option in m_config_new that has the address in the option's private data. asxparser.c also used the global. Making it available through all ways the code could get called required a number of relatively straightforward changes to playtree and menu code.
* | Convert m_config.c to use tallocUoti Urpala2008-04-261-62/+32
| |
* | Start of new option systemUoti Urpala2008-04-231-9/+32
|/ | | | | | | | First part of option restructuring. The aim is to move option values from a huge number of separate globals to a single non-global struct. This part adds some support for parsing option values into such struct instances, and moves one example option (fixed-vo) to the struct.
* Replace the trivial command line preparser with a more robust versionalbeu2008-04-131-0/+7
| | | | | | <