summaryrefslogtreecommitdiffstats
path: root/options/m_config.c
Commit message (Collapse)AuthorAgeFilesLines
* m_config: remove a redundant conditionwm42018-05-241-3/+1
| | | | Always true, because a few lines above it checks for the same thing.
* m_config: fix build with emulated stdatomicwm42018-05-241-2/+3
| | | | | | | | | | | | C11 can access atomic variables normally (in which case they use the strictest memory access semantics). But the mpv stdatomic wrapper for C99 compilers does not allow it, because it couldn't give any guarantees. This means we always need to access them with atomic macros. While we're at, use relaxed semantics for the m_config_cache field, since because it's accessed from a single thread only (essentially used in a non-atomic way). Switch the comparison arguments to make the formatting look slightly less weird.
* m_config: make m_config_cache_update() return more fine grainedwm42018-05-241-3/+7
| | | | | | | | | Although the new code actually fires update notifications only when needed, m_config_cache_update() itself returned a rather coarse change value, which could indicate change even if none of the cached options were changed. On top of that, some code (like vo_gpu) calls the update function on every frame, which would reconfigure the renderer even on unrelated option changes.
* m_config: optimize initialization of each optionwm42018-05-241-5/+9
| | | | | | | | | | | | | | | | | | | | | | Options with dynamic memory allocations (such as strings) require some care. They need to be fully copied on initialization, and if a static default value was declared, we must not free that value either. Instead of going through the entire thing even for simple types like integers, really run it only for options with dynamic allocations. To distinguish types which use dynamic allocations, we can use the fact that they require a free callback (otherwise they would leak). As a result initialization of simple types becomes chaper, and the init function does nothing at all if src==dst for a simple type. (It's funny how mplayer had M_OPT_TYPE_DYNAMIC since 2002, until we replaced it by the same heuristic as used here in commit 3bb134969eb6. It's also funny how the new check was used only for some asserts, and finally removed in commit 7539928c1c. I guess at this time I felt like having uniform code was more important than pointless micro-optimizations.) The src==NULL case is removed because it can't happen.
* m_config: remove extra default_data fieldwm42018-05-241-16/+23
| | | | Just wastes memory (a few KB, because there are so many options).
* m_config: remove unused fieldswm42018-05-241-3/+2
|
* m_config: reduce redundant option change notificationswm42018-05-241-1/+1
|
* m_config: remove an old temporary hackwm42018-05-241-297/+323
| | | | | | | | | | | | | | | | Actually rewrite most of the option management code. This affects how options are allocated, and how thread-safe access to them is done. One thing that is nicer is that creating m_config_cache does not need to ridiculously recreate and store the entire option list again. Instead, option metadata and option storage are now separated. m_config contains the metadata, and m_config_data all or parts of the actual option values. (m_config_cache simply uses the metadata part of m_config, which is immutable after creation.) The mentioned hack was introduced in commit 1a2319f3e4cc4, and is the global state around g_group_mutex. Although it was "benign" global state, it's good that it's finally removed.
* m_config: check for int16_t offset overflowwm42018-05-241-1/+3
| | | | | | | | For some reason shadow_offset is a int16_t variable (to save some space or something), which means the static part of the entire option list must be below 32KB. This is fine, but still add a check against overflows. (Currently it's 3.6KB. This does not include dynamic allocations like strings.)
* m_config: remove an unused functionwm42018-05-241-11/+0
|
* m_config: cosmetics: fix 2 typoswm42018-05-241-2/+2
|
* options: minor cleanup to --no-... handlingwm42018-02-131-5/+5
| | | | | | | | Most options starting with --no-<name> are automatically translated to --<name>=no. Make the code slightly nicer by using a flag instead of explicitly comparing option types. Also fix an issue that made the option parser print nonsense error messages for if --no-... was used for options which don't support it.
* options: prefix option with "--" in one case in help outputwm42018-02-131-1/+1
|
* options: pretty print default values with --list-optionswm42018-02-011-1/+1
|
* options: simplify mp_get_config_group() memory managementwm42018-01-181-2/+4
| | | | | | | | | | | | | | | | There is some craziness here: the function allocates m_config_cache, which in turn allocates the actual option struct, which is what the function returns. The user would expect to be able to use talloc_free() to deallocate everything. Of course this didn't work, because the returned pointer is not the root parent in the talloc tree. But with some additional talloc craziness, this can be fixed. We rearrange the parent pointers such that freeing the option struct will free m_config_cache first, which uninits the contents in the option struct, but fortunately not the option struct itself. This change should simplify API use on the caller side, and reduce surprises.
* options: don't warn when reading deprecated option as raw valuewm42018-01-181-1/+1
| | | | | | mp_read_option_raw() should not print the deprecation warning if the option is deprecated. This change also means you can't pass an alias to the function, but all existing uses should be fine.
* audio: add global options for resampler defaultswm42018-01-131-5/+12
| | | | | | | | This is part of trying to get rid of --af-defaults, and the af resample filter. It requires a complicated mechanism to set the defaults on the resample filter for backwards compatibility.
* options: move most subtitle and OSD rendering options to sub structswm42018-01-021-0/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | Remove them from the big MPOpts struct and move them to their sub structs. In the places where their fields are used, create a private copy of the structs, instead of accessing the semi-deprecated global option struct instance (mpv_global.opts) directly. This actually makes accessing these options finally thread-safe. They weren't even if they should have for years. (Including some potential for undefined behavior when e.g. the OSD font was changed at runtime.) This is mostly transparent. All options get moved around, but most users of the options just need to access a different struct (changing sd.opts to a different type changes a lot of uses, for example). One thing which has to be considered and could cause potential regressions is that the new option copies must be explicitly updated. sub_update_opts() takes care of this for example. Another thing is that writing to the option structs manually won't work, because the changes won't be propagated to other copies. Apparently the only affected case is the implementation of the sub-step command, which tries to change sub_delay. Handle this one explicitly (osd_changed() doesn't need to be called anymore, because changing the option triggers UPDATE_OSD, and updates the OSD as a consequence). The way the option value is propagated is rather hacky, but for now this will do.
* msg: reinterpret a bunch of message levelsNiklas Haas2017-12-151-4/+4
| | | | | | | | | | | | | | | | | | | | | | I've decided that MP_TRACE means “noisy spam per frame”, whereas MP_DBG just means “more verbose debugging messages than MSGL_V”. Basically, MSGL_DBG shouldn't create spam per frame like it currently does, and MSGL_V should make sense to the end-user and provide mostly additional informational output. MP_DBG is basically what I want to make the new default for --log-file, so the cut-off point for MP_DBG is if we probably want to know if for debugging purposes but the user most likely doesn't care about on the terminal. Also, the debug callbacks for libass and ffmpeg got bumped in their verbosity levels slightly, because being external components they're a bit less relevant to mpv debugging, and a bit too over-eager in what they consider to be relevant information. I exclusively used the "try it on my machine and remove messages from MSGL_* until it does what I want it to" approach of refactoring, so YMMV.
* m_config: better variable namewm42017-09-221-5/+5
|
* options: properly handle deprecated options with CLI actionswm42017-09-221-8/+23
| | | | | | | | We want e.g. --opengl-shaders-append=foo to resolve to the new option, all while printing an option name. --opengl-shader is a similar case. These options are special, because they apply "actions" on actual options by specifying a suffix. So the alias/deprecation handling has to be part of resolving the actual option from prefix and suffix.
* options: add a thread-safe way to notify option updateswm42017-08-221-1/+90
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | So far, we had a thread-safe way to read options, but no option update notification mechanism. Everything was funneled though the main thread's central mp_option_change_callback() function. For example, if the panscan options were changed, the function called vo_control() with VOCTRL_SET_PANSCAN to manually notify the VO thread of updates. This worked, but's pretty inconvenient. Most of these problems come from the fact that MPlayer was written as a single-threaded program. This commit works towards a more flexible mechanism. It adds an update callback to m_config_cache (the thing that is already used for thread-safe access of global options). This alone would still be rather inconvenient, at least in context of VOs. Add another mechanism on top of it that uses mp_dispatch_queue, and takes care of some annoying synchronization issues. We extend mp_dispatch_queue itself to make this easier and slightly more efficient. As a first application, use this to reimplement certain VO scaling and renderer options. The update_opts() function translates these to the "old" VOCTRLs, though. An annoyingly subtle issue is that m_config_cache's destructor now releases pending notifications, and must be released before the associated dispatch queue. Otherwise, it could happen that option updates during e.g. VO destruction queue or run stale entries, which is not expected. Rather untested. The singly-linked list code in dispatch.c is probably buggy, and I bet some aspects about synchronization are not entirely sane.
* options: fix --includewm42017-08-081-0/+2
| | | | | | | | This is really obnoxious. --include parses into the default profile, but when used on the command line, it did never get applied. So we have to apply it when the exact conditions for this are met. Fixes #4673.
* client API: drop some compatibility handlingwm42017-07-211-13/+2
| | | | See commit e4bc563fd2dcf for more information.
* options: change everything againwm42017-07-021-3/+26
| | | | Fucking bullshit.
* m_option: remove redundant indirectionswm42017-07-021-27/+23
| | | | | | Remove the various redundant m_config_set_option* calls, rename the remaining one to m_config_set_option_cli(), and merge the m_config_parse_option() function.
* options: list suffix actions as options toowm42017-06-271-2/+7
| | | | | | | These are not "really" separate actions, but on the command line they're obserable as such. So it would be a good idea to list them too. Adds about 117 options (holy fuck).
* options: handle suffixes like -add in a more generic waywm42017-06-261-28/+66
| | | | | | | | | | | | | | | | This affects options like --vf or --display-tags. These used a "*" suffix to match all options starting with a specific name, and handled the rest in the option parser. Change this to remove the "*" special case, and require every option parser to declare a list of allowed suffixes via m_option_type.actions. The new way is conceptually simpler, because we don't have to account for the "*" in a bunch of places anymore, and instead everything is centrally handled in the CLI part of the option parser, where it's actually needed. It automatically enables suffixes like -add for a bunch of other stringlist options.
* client API: drop old "no-" option emulationwm42017-06-261-22/+2
| | | | | | | You could do mpv_set_option(h, "no-fs", ""), which would behave like "--no-fs" on the command line. At one point, this had to be emulated for compatibility, and printed a deprecation warning. This was almost a year ago, so remove it.
* options: make mess to allow setting profile option with libmpvwm42017-06-151-81/+81
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Certain options, such as --profile, --help, and many others require special-handling, because they don't fit conceptually into the option and property model. They don't store data, but perform actions. This caused the situation that profiles could not be set when using libmpv in encoding mode (although you should probably not used libmpv in encoding mode). Using libmpv always ends up in calling m_config_set_option_raw_direct(), while --profile was handled in m_config_parse_option(). Solve this by moving the handling of this from m_config_parse_option() to m_config_set_option_raw_direct(). Actually we just stuff most of this into m_config_handle_special_options(), which is only called by the aforementioned function. Strangely this also means that the --h/--help option declarations need to be changed, because they used OPT_PRINT, and now the option "parser" is always invoked before the special code. Thus, make them a string. Them being OPT_PRINT was apparently always redundant. (The other option declarations are moved for cosmetic purposes only.) The most weird change is how co->data==NULL is handled. We now allow passing down involved options to m_config_set_option_raw_direct(). The thing is that we don't want them to error if the command line parser is using them (with special handling done there), while all other code paths should raise an error. We try using M_SETOPT_FROM_CMDLINE to distinguish these cases. Note that normal libmpv users are supposed to use the "apply-profile" command instead. This probably contains a bunch of bugs, which you should report.
* options: change license of most files to LGPL (except options.c/.h)wm42017-06-121-7/+7
| | | | | | | | | | | | | | | | | | | | | | | All authors of the current code have agreed (as far as this commit requires). options.c/options.h will take more effort, because it contains all the option declarations, and thus is touched extremely often. m_option.c is technically still GPL, because of commit 2c82d5a1d85378dd0 (michael has agreed to LGPL, but only once the core of mpv is LGPL). The geometry parsing code in m_option.c was originally by someone who could not be reached. However, it was heavily rewritten anyway, and only the syntax remains (i.e. not copyright-relevant). parse_commandline.c contains a change by "adland" (commit 1d0ac71ae8ba), who could not be reached - this this specific part is GPL only. Fortunately, it matters only for DVD (and even then is more like a hack, but whatever). There are some other relevant changes, but they have all been reverted, moved somewhere else, deleted, or replaced.
* options: deprecate --loopwm42017-04-101-5/+9
| | | | | | | | | | Also "announce" the plans to undeprecate it with changed semantics later. The deprecation period is needed to warn script authors and client API users (etc.) of the change. This is done because everyone seems to expect --loop to loop the current file, not the playlist. Even in cases when only 1 file is on the playlist, the --loop-file semantics seem to be preferred.
* options: change --h=... behaviorwm42016-12-161-7/+1
| | | | | Does not match a shell pattern anymore. Instead, a simple sub-string search is done.
* options: some simplificationswm42016-11-291-36/+17
| | | | | | | | Remove more stuff that was needed only for legacy suboptions. One user-visible change is that parent-options like --tv are now not visible anymore. They lead to a special error message when used before, but now they're simply not part of the option list anymore.
* options: remove deprecated sub-option handling for --vo and --aowm42016-11-251-65/+100
| | | | | | | | Long planned. Leads to some sanity. There still are some rather gross things. Especially g_groups is ugly, and a hack that can hopefully be removed. (There is a plan for it, but whether it's implemented depends on how much energy is left.)
* options: remove legacy global sub-option syntaxwm42016-11-221-54/+3
| | | | | | A bit of sanity, although a very small one. --vo sub-options are not affected by this yet.
* options: fnmatch: check existence instead of posixAvi Halachmi (:avih)2016-11-081-1/+0
|
* options: handle legacy no-* sub-optionswm42016-10-211-8/+21
| | | | | | | | These accidentally did nothing. They must be handled explicitly. Example: --vo=vdpau:no-composite-detect (Can't wait to get rid of this crap.)
* player: do not let pseudo-gui override user config settingswm42016-09-231-0/+7
| | | | | | | | Seems like this confused users quite often. Instead of --profile=pseudo-gui, --player-operation-mode=pseudo-gui now has to be used to invoke pseudo GUI mode. The old way still works, and still behaves in the old way.
* m_config, command: remove some minor code duplicationwm42016-09-231-3/+7
| | | | | | I would have been fine with this, but now I want to add another flag, and the duplication would become more messy than having a strange function for deduplication.
* client API: more or less deprecate mpv_set_option()wm42016-09-211-1/+3
| | | | | | | | | | | | | | | | | | | | | | With the merging of options and properties, the mpv_set_option() function is close to being useless, and mpv_set_property() can be used for everything instead. There are certain conflicts remaining, which are explained in depth in the docs. For now, none of this should affect existing code using the client API. Make mpv_set_property() redirect to mpv_set_option() before initialization. Remove some options marked as M_OPT_FIXED. The "pause" and "speed" options cannot be written anymore without the playloop being notified by it, so the M_OPT_FIXED does nothing. For "vo-mmcss-profile", the problem was lack of synchronization, which has been added. I'm not sure what the problem was with "frames" - I think it was only marked as M_OPT_FIXED because changing it during playback will have no effect. Except for pause/speed, these changes are needed to make them writable as properties after mpv_initialize(). Also replace all remaining uses of CONF_GLOBAL with M_OPT_FIXED.
* options: slightly better option update mechanismwm42016-09-191-7/+17
| | | | | | | | | | | | | | Extend the flag-based notification mechanism that was used via M_OPT_TERM. Make the vo_opengl update mechanism use this (which, btw., also fixes compilation with OpenGL renderers forcibly disabled). While this adds a 3rd mechanism and just seems to further the chaos, I'd rather have a very simple mechanism now, than actually furthering the mess by mixing old and new update mechanisms. In particular, we'll be able to remove quite some property implementations, and replace them with much simpler update handling. The new update mechanism can also more easily refactored once we have a final mechanism that handles everything in an uniform way.
* player: more option/property consistency fixeswm42016-09-181-5/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* options: take care of propertly updating options on runtime changeswm42016-09-171-3/+23
| | | | | | | | | | | | | | | | | | | | | | All option write accesses are now put through the property interface, which means runtime option value verification and runtime updates are applied. This is done even for command line arguments and config files. This has many subtle and not-so-subtle consequences. The potential for unintended and intended subtle or not-subtle behavior changes is very large. Architecturally, this is us literally jumping through hoops. It really should work the other way around, with options being able to have callbacks for value verification and applying runtime updates. But this would require rewriting the entirety of command.c. This change is more practical, and if anything will at least allow incremental changes. Some options are too incompatible for this to work - these are excluded with an explicit blacklist. This change fixes many issues caused by the mismatch between properties and options. For example, this fixes #3281.
* options: fix pseudo-options like -vwm42016-09-171-1/+1
| | | | | | | Some pseudo-options do not have associated storage, which made m_config_set_option_raw() return failure. Regression due to commit d1d5e9dd.
* options: simplify M_OPT_EXITwm42016-09-171-7/+7
| | | | | | | | | | | | | There were multiple values under M_OPT_EXIT (M_OPT_EXIT-n for n>=0). Somehow M_OPT_EXIT-n either meant error code n (with n==0 no error?), or the number of option valus consumed (0 or 1). The latter is MPlayer legacy, which left it to the option type parsers to determine whether an option took a value or not. All of this was changed in mpv, by requiring the user to use explicit syntax ("--opt=val" instead of "-opt val"). In any case, the n value wasn't even used (anymore), so rip this all out. Now M_OPT_EXIT-1 doesn't mean anything, and could be used by a new error code.
* m_config: make option setting always call m_config_set_option_raw()wm42016-09-171-14/+20
| | | | | | | | | | This makes m_config_set_option_raw() the function that is always called on the lowest level (as leaf function for all other functions). To do this, m_config_parse_option() has to do something special to deal with "impure" options like --vf-add, which work on the previous option value, instead of fully replacing it. m_config_set_option_raw() itself always completely replaced the previous value.
* options: kill M_OPT_GLOBAL flagwm42016-09-171-13/+2
| | | | | | This meant "cannot be used as per-file option" (wrt. playlist items). Doesn't make too much sense anymore, especially gi