Commit Graph

26 Commits

Author SHA1 Message Date
wm4 b5d253a5cb m_config: fix theoretic undefined behavior
The memcpy() is actually not enough: the types are incompatible, and no
memcpy, union, etc. will change that. (Although no real compiler will
ever break this.) Attempt to make this theoretically correct by actually
using a struct pointer. It's not the same struct type, but supposedly
it's ok, because all struct pointers always have the same size and
representation in standard C.
2014-09-13 01:27:54 +02:00
wm4 0b428e4482 player: redo how stream caching and pausing on low cache works
Add the --cache-secs option, which literally overrides the value of
--demuxer-readahead-secs if the stream cache is active. The default
value is very high (10 seconds), which means it can act as network
cache.

Remove the old behavior of trying to pause once the byte cache runs
low. Instead, do something similar wit the demuxer cache. The nice
thing is that we can guess how many seconds of video it has cached,
and we can make better decisions. But for now, apply a relatively
naive heuristic: if the cache is below 0.5 secs, pause, and wait
until at least 2 secs are available.

Note that due to timestamp reordering, the estimated cached duration
of video might be inaccurate, depending on the file format. If the
file format has DTS, it's easy, otherwise the duration will seemingly
jump back and forth.
2014-08-27 03:39:04 +02:00
wm4 f8c2dd1b78 build: include <strings.h> for strcasecmp()
It happens to work without strings.h on glibc or with _GNU_SOURCE, but
the POSIX standard requires including <strings.h>.

Hopefully fixes OSX build.
2014-07-10 08:29:32 +02:00
wm4 49df035514 options: remove bogus replacement message for --fstype
CC: @mpv-player/stable
2014-07-05 17:07:16 +02:00
wm4 962b928192 options: add --autosub-match to option replacement list
CC: @mpv-player/stable
2014-07-05 17:07:16 +02:00
wm4 b7bedbbc36 options: remove some more stuff
The "classic" sub-option stuff is not really needed anymore. The only
remaining use can be emulated in a simpler way. But note that this
breaks the --screenshot option (instead of the "flat" options like
--screenshot-...). This was undocumented and discouraged, so it
shouldn't affect anyone.
2014-06-13 02:18:26 +02:00
wm4 a64e099efc options: remove some unneeded stuff
No options pointing to global variables are in use anymore, so that part
can be removed.
2014-06-13 02:16:47 +02:00
wm4 6a4a5595d8 options: remove OPT_FLAG_CONSTANTS
This means use of the min/max fields can be dropped for the flag option
type, which makes some things slightly easier. I'm also not sure if the
client API handled the case of flag not being 0 or 1 correctly, and this
change gets rid of this concern.
2014-06-13 02:10:45 +02:00
wm4 98a31d5937 options: turn --idx, --forceidx into --index
Also clarify the semantics.

It seems --idx didn't do anything. Possibly it used to change how the
now removed legacy demuxers like demux_avi used to behave. Or maybe
it was accidental.

--forceidx basically becomes --index=force. It's possible that new
index modes will be added in the future, so I'm keeping it
extensible, instead of e.g. creating --force-index.
2014-06-13 02:05:37 +02:00
wm4 99f5fef0ea Add more const
While I'm not very fond of "const", it's important for declarations
(it decides whether a symbol is emitted in a read-only or read/write
section). Fix all these cases, so we have writeable global data only
when we really need.
2014-06-11 00:39:14 +02:00
wm4 98c0930f9b m_config: add function to copy subopt-struct 2014-06-11 00:34:41 +02:00
wm4 4664f8b3b7 cache: redo options and default settings
Some options change from percentages to number of kilobytes; there are
no cache options using percentages anymore.

Raise the default values. The cache is now 25000 kilobytes, although if
your connection is slow enough, the maximum is probably never reached.
(Although all the memory will still be used as seekback-cache.)

Remove the separate --audio-file-cache option, and use the cache default
settings for it.
2014-05-20 02:40:22 +02:00
wm4 caa939aa91 options: unify code for setting string and "raw" options
The code paths for setting options by string and by direct "raw" value
were too different, which resulted in some weird code. Make the code
paths closer to each other.

Also, use this to remove the weirdness in the mpv_set_option()
implementation.
2014-05-18 19:21:39 +02:00
wm4 7fb5df0d3e options: print replacement for renamed/replaced options
Basically, extract the option table from DOCS/man/en/changes.rst, and
search the table if an option wasn't found. If there's an entry about
it, print it. Hopefully this behavior is slightly more userfriendly.

This is strictly bound to option names. It doesn't work for option
values, nor does it attempt to emulate the old option.
2014-05-05 23:56:01 +02:00
wm4 b430c886aa client API: make mpv_set_option set options natively
This should fix some issues, such as not being able to set the
"no-video" option with MPV_FORMAT_FLAG.

Note that this changes semantics a bit. Now setting an option strictly
overwrite it, even if the corresponding command line option does not.
For example, if we change --sub to append by default, then setting the
"sub" option via the client API would still never append. (Oddly, this
also applies to --vf-add, which will overwrite the old value when using
the client API.)

I'm doing this because there's no proper separation between the command
line parser and setting an option using the MPV_FORMAT_STRING format.
Maybe the solution to this mess would be adding format aware code (i.e.
m_option_set_node) to every option type, and falling back to strings
only if needed - but this would mean that you couldn't set e.g. an
integer option using MPV_FORMAT_STRING, which doesn't seem to be ideal
either.

In conclusion, the current approach seems to be most robust, but I'm
open to suggestions should someone find that these semantics are a
problem.
2014-04-22 01:42:57 +02:00
wm4 b85983a4a6 encode: don't apply default config options
Often, user configs set options that are not suitable for encoding.
Usually, playback and encoding are pretty different things, so it makes
sense to keep them strictly separate. There are several possible
solutions. The approach taken by this commit is to basically ignore the
default config settings, and switch to an [encoding] config profile
section instead. This also makes it impossible to have --o in a config
file, because --o enables encode mode.

See github issue #727 for discussion.
2014-04-19 22:05:17 +02:00
wm4 839c3ae64b options: don't sort sub-option help output
Commit 2c2c1203 sorted the output of --list-options, but the same code
ias also used for listing sub-options, such as --vo=scale:help. For sub-
options, the order actually matters.
2014-04-12 11:38:00 +02:00
wm4 2c2c1203c3 options: sort --list-options
Until now, --list-options printed options in random order. There
literally wasn't any logic in its order, they just appeared as they were
declared. So just sort them.

Note that we can't sort them in advance, because for certain things
internal to m_config, the order actually matters.

Also we're using strcasecmp(), which is bad (locale dependent), but this
is output intended for human consumption, so it's not a problem.
2014-04-11 01:39:30 +02:00
wm4 e749470018 options: fix --list-options output
This was a bit damaged by commit f3c933e5.
2014-02-26 21:03:35 +01:00
wm4 4d1575173b command: make options property return the list of all options 2014-02-24 22:50:24 +01:00
wm4 942fb43d0c client API: implement setting options using their native type too
This is only half-implemented: actually the option will first be
converted from mpv_node to its native type, then it's converted to a
string, and then back to its native type. This is because the option
API was made for strings and not anything else.

Other than being grossly inelegant, the only downside is probably with
string lists and key/value lists, which don't escape strings containing
syntax elements correctly.
2014-02-24 22:50:23 +01:00
wm4 fd081c467d options: print any options set in verbose mode
So we will know whether someone uses broken config file options when
posting a log with -v.
2013-12-23 17:30:19 +01:00
wm4 d8d42b44fc m_option, m_config: mp_msg conversions
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.
2013-12-21 21:05:02 +01:00
wm4 dadf3a9a46 m_config: add custom context to includefunc callback 2013-12-21 20:50:13 +01:00
wm4 0112143fda Split mpvcore/ into common/, misc/, bstr/ 2013-12-17 02:39:45 +01:00
wm4 eb15151705 Move options/config related files from mpvcore/ to options/
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.
2013-12-17 02:07:57 +01:00