Commit Graph

221 Commits

Author SHA1 Message Date
wm4 75e1c6f295 m_config: allow not allocating option struct, and use it
In cases we're just listing options or checking their values (as it
happens with -vo/-vf etc. suboption parsing), we don't need to allocate
abd initialize the actual option struct. All we're interested in is
the list of options.
2013-10-25 18:39:15 +02:00
wm4 60aea74f44 m_config: refactor option defaults handling
Keep track of the default values directly, instead of creating a new
instance of the option struct just to get the defaults.

Also get rid of the special handling of m_obj_desc.init_options.
Instead, handle it purely by the option parser. Originally, I wanted to
handle --vo=opengl-hq and --vo=direct3d_shaders with this (by making
them aliases to the real VOs with a different preset), but since --vo
=opengl-hq=help prints the wrong values (as consequence of the
simplification), I'm not doing that, and instead use something
different.
2013-10-24 22:50:13 +02:00
wm4 f6bceacaff options: fix bogus entry
This didn't make sense and caused issues with the following commit: if
it's an option with a data pointer, it should be writable.
2013-10-24 22:50:13 +02:00
wm4 7204dee3c7 m_config: don't require dragging along parent in initialization
Instead, track the opstruct explicitly. It turns out we don't need the
parent at all. Also, add something rudimentary to track the default
values.
2013-10-24 22:50:13 +02:00
wm4 b707589e7e m_config: minor simplification
I think in this case, having a separate function is confusing.
2013-10-24 22:50:13 +02:00
wm4 4cd143e4d8 m_config: store m_config_options in an array instead of a list
Might reduce memory overhead, and is also less annoying.

Since pointers to m_config_options are kept around, this assumes
they're added only during initialization. Otherwise you'd get
dangling pointers.
2013-10-24 22:50:13 +02:00
wm4 a217c08b17 m_config: refactor initialization, reduce amount of malloc'ed strings
Allocate strings only if needed (when we have to prefix sub-options).
Prepare for storing m_config_options in an array instead of a list.
2013-10-24 22:50:13 +02:00
wm4 cfc72d4fff m_config: slightly simplify dynamic option initialization
We can assume memcpy is enough, because the source should be from
static data. (It wouldn't work if the data could contain pointers
back into itself.)
2013-10-24 22:50:13 +02:00
wm4 8d5f8d5a6b m_config: don't allow aliasing with string options
Minor simplification. String options are now not allowed to use the
same variable/field anymore. (Also affects other "dynamic" options
which require memory allocation.)
2013-10-24 22:50:13 +02:00
wm4 cc235d203d m_config: cosmetics: make code less verbose 2013-10-24 22:50:13 +02:00
wm4 d58d4ec93c audio/out: remove useless info struct and redundant fields 2013-10-23 19:30:02 +02:00
wm4 e60b8f181d audio/filter: split af_format into separate filters, rename af_force
af_format is the old audio conversion filter. It could do all possible
conversions supported by the audio chain. However, ever since the
addition of af_lavrresample, most conversions are done by
libav/swresample, and af_format is used as fallback.

Separate out the fallback cases and remove af_format. af_convert24 does
24 bit <-> 32 bit conversions, while af_convertsignendian does sign and
endian conversions. Maybe the way the conversions are split sounds a bit
odd. But the former changes the size of the audio data, while the latter
is fully in-place, so there's at least different buffer management.

This requires a quite complicated algorithm to make sure all these
"partial" conversion filters can actually get from one format to
another. E.g. s24le->s32be always requires convertsignendian and
convert24, but af.c has no idea what the intermediate format should
be. So I added a graph search (trying every possible format and
filter) to determine required format and filter. When I wrote this,
it seemed this was still better than messing everything into
af_lavrresample, but maybe this is overkill and I'll change my
opinion. For now, it seems nice to get rid of af_format though.

The AC3->IEC61937 conversion isn't supported anymore, but I don't think
this is needed anywhere. Most AOs test all formats explicitly, or use
the AF_FORMAT_IS_IEC61937() macro (which includes AC3).

One positive consequence of this change is that conversions always
include dithering (done by libav/swresample), instead of possibly going
through af_format, which doesn't do anything fancy.

Rename af_force to af_format. It's essentially compatible with command
line uses of af_format. We retain a compatibility alias for af_force.
2013-10-23 10:04:12 +02:00
wm4 da6093a5a1 mplayer: don't call libquvi for local files
This is obviously not needed, and just creates potential for bad
breakages (e.g. what happens if libquvi tries to open a normal filename
as http URL?).

Note that for simplicity, we still pass file:// URIs to quvi, and we
don't exclude other protocol prefixes either. In general, we don't know
what protocols quvi might support, so we don't try to second-guess it.
(Even though in practice, it's probably only "http" and "https".)
2013-10-20 21:33:27 +02:00
wm4 afa9e50587 input: fix --input-ar-rate=0
Crashed, instead of disabling auto-repeat.
2013-10-20 13:55:10 +02:00
wm4 f50b105d06 tl_matroska: fix use-after-free with --cache
If cache was enabled, using ordered chapters could easily crash. The
reason is that enable_cache() reopens the demuxer and closes the old
one. The code after that (reading m->ordered_chapters etc.) then
accessed freed data.

This commit also avoids enabling cache for files which are not used
(which would make opening much slower).
2013-10-19 22:58:02 +02:00
wm4 d2d0bc31bf mp_talloc: simplify a bit
Implement MP_GROW_ARRAY using MP_TARRAY_GROW. MP_GROW_ARRAY is basically
the earlier version of MP_TARRAY_GROW, and had different semantics. When
I added MP_TARRAY_GROW, I didn't dare to change it, but I think all code
that relied on the exact semantics of MP_GROW_ARRAY is gone now, or the
difference doesn't matter anyway. The semantic change is that now
(n+1)*2 elements are preallocated instead of n*2.

Also, implement MP_TARRAY_GROW using MP_RESIZE_ARRAY, which saves 1 line
of code.

In future, these macros should be part of TA.
2013-10-19 21:43:08 +02:00
wm4 e046fa584a mp_msg: remove gettext() support
Was disabled by default, was never used, internal support was
inconsistent and poor, and there has been virtually no interest in
creating translations.

And I don't even think that a terminal program should be translated.
This is something for (hypothetical) GUIs.
2013-10-18 22:38:10 +02:00
wm4 fd0ffa7b40 mplayer: mp_msg replacements
Not 100% complete; not touching the more complicated cases.
2013-10-18 21:59:52 +02:00
ChrisK2 6e34322dec osc: make transparency of background-box configurable
see boxalpha option
2013-10-18 00:33:01 +02:00
wm4 af0306d48d Merge Matroska ordered chapter changes
This adds support for ChapterSegmentEditionUID (pull request #258),
and also fixes issue #278 (pull request #292).

In fact, this is a straight merge of pr/292, which also contains pr/258.
2013-10-17 00:32:14 +02:00
Alessandro Ghedini de3a979f69 spelling fixes 2013-10-16 12:36:34 +02:00
Ben Boeckel 1b30a0bbf9 matroska: don't add time for chapters without a source 2013-10-15 21:16:05 -04:00
Ben Boeckel 648e8fbeed matroska: log about where missing time comes from 2013-10-15 21:04:16 -04:00
Ben Boeckel 78545fee42 matroska: only error if at least a millisecond is missing 2013-10-15 20:53:10 -04:00
Ben Boeckel abee328f20 matroska: account for missing information from short sources
If a source is shorter than the requested chapter length, account for
the time missing.
2013-10-15 20:53:10 -04:00
Ben Boeckel e80fd3f9e1 matroska: modify chapter limits by join_diff
When adding or removing frames to avoid 1-frame seeks on chapter
boundaries, the end of the chapter needs to be pushed or pulled by the
same amount to keep the intended end frame the same.
2013-10-15 20:46:38 -04:00
ChrisK2 71b0c2b88c osc: fix borked options 2013-10-15 22:41:19 +02:00
ChrisK2 a54ca2da31 osc docs: Add documentation for OSC and rename some options
camelCase from some of the option names removed. If you were using those, you'll have to update them in your config.
2013-10-15 22:30:33 +02:00
ChrisK2 97770473d0 osc: reset mouse position when leaving window
and store it freshly on first mouse_move event when entering again
2013-10-15 21:49:06 +02:00
ChrisK2 dd3e52fe68 osc: Don't create a config if none exists.
A documentation explaing where and how to create one instead will follow.
2013-10-15 01:17:34 +02:00
wm4 f0a5ff39a1 osc: use "info" instead of "warn" for config file creation message
When the main mpv config file, "info" is used, so this makes things
consistent.
2013-10-14 23:48:18 +02:00
wm4 cf02e515d4 parser-cfg: allow putting options with leading "--"
Now you can pretend the config file is quite literally command line
values dumped into a file, e.g.

--option1=value
--option2=value
...

although the underlying mechanisms are quite different.
2013-10-14 23:41:26 +02:00
wm4 c7dee24c8c parser-cfg: use bstr everywhere after parsing stage
Until now it used both char[] and bstr variants in the same code, which
was nasty. For example, the next commit would have additionally required
using memmove() to remove the prefix from the char[] string.
2013-10-14 23:37:58 +02:00
wm4 8c234045fa options: enable OSC by default
Can can disable it with --osc=no.
2013-10-14 21:09:54 +02:00
wm4 24fffa0f6b mplayer: escape strings if needed when writing watch_later config
This fixes handling of e.g. "--vf=lavfi=[ noise ]" when used with
playback resume functionality. The spaces made it bug out, and there are
more cases where it could potentially break.

We could always escape for simplicity, but for now make old and new mpv
builds somewhat interoperable and use this new escaping only if needed.
2013-10-14 21:05:58 +02:00
wm4 5106edfd5e parser-cfg: parse % escapes
This parses "%len%string" escapes, where string can contain any
characters. This method of escaping has also been used in other parts
of mplayer and mpv, so it's not a new idea.

(Also, don't confuse with URL encoding.)

Needed by the following commit.
2013-10-14 21:04:58 +02:00
wm4 0f1764195a mplayer: print ffmpeg library versions along with mpv version info
Also change what the FFmpeg version info looks like, and additionally
dump lavfi/lavr/lswr versions. (Don't bother with libavdevice and
libpostproc, they're not important enough.)

Unfortunately, there's no "single" FFmpeg/Libav version due to fatal
braindeath on the FFmpeg/Libav side. We can't map the versions to
releases either (it simply isn't accessible anywhere).
2013-10-14 20:14:17 +02:00
ChrisK2 683da7411e osc: raise minmousemove default setting to 3 and disable input mouse area when OSC not visible
The mouse area that covers the OSC is now only activated when the OSC is actually visible, to make sure the mouse still hides if it happens to be parked in the OSC area without making the OSC show up.
2013-10-14 19:51:16 +02:00
wm4 94e71b7cc0 mplayer, vo_image: simplify OSD redrawing, fix vo_image crash
vo_image didn't handle OSD redrawing correctly anymore after OSD
redrawing behavior was changed in commit ed9295c (or maybe it has been a
problem for a longer time, and only showed up now). Basically, flip_page
was called unexpectedly and when no image was stored, which made it
crash trying to access the image. This could happen when for example
provoking OSD redrawing by pausing while using --vo=image, or by using
this command line: mpv --vo=image '-vf=lavfi="select=not(mod(n\,3))"'

Fix by removing the code that pretends vo_image can redraw OSD, and by
removing the framestepping fallback, which could make bad things happen
if the VO didn't support OSD redrawing. By now, there aren't any real
VOs that can't redraw the OSD properly, so this code is not needed and
just complicates things like vo_image.

This change likely will also be useful for vo_lavc (encoding).
2013-10-13 23:40:23 +02:00
wm4 eeac26410f mplayer: print a warning if libass is not compiled
Libass is technically an optional dependency, but in practice users
tend to disable libass accidentally or for the hell of it to get
something "minimal", without being aware of the consequences.
2013-10-13 22:25:33 +02:00
ChrisK2 1560d6ce60 osc: fix mouse hiding 2013-10-13 05:38:13 +02:00
ChrisK2 9b20c681fd osc: Once again new Show/Hide handling
The deadzone-size is now by default zero, so movement on the entire window will make the OSC show up. To avoid it showing up by randomly moving mice, the option 'minmousemove' controls how many pixels movement (default: 1) between ticks (frames) are necessary to make the OSC show up.
The deadzone can be reenabeled by setting the option 'deadzonesize' (default: 0 = no deadzone, 1 = entire area between OSC and opposite window border), to restore the old behavior, set it to ~0.92.

The OSC will hide immediately when leaving the window or entering the deadzone (if existing) or after the time specified with 'hidetimeout' (default: 500ms) passed without any new movement. Set to negative value to disabling auto-hide (thus restoring old behavior). The OSC will never hide if hovered by the mouse.
2013-10-13 03:51:25 +02:00
wm4 c613d802bc talloc: change talloc destructor signature
Change talloc destructor so that they can never signal failure, and
don't return a status code. This makes our talloc copy even more
incompatible to upstream talloc, but on the other hand this is
preparation for getting rid of talloc entirely.

(The talloc replacement in the next commit won't allow the talloc_free
equivalent to fail, and the destructor return value would be useless.
But I don't want to change any mpv code either; the idea is that the
talloc replacement commit can be reverted for some time in order to
test whether the talloc replacement introduced a regression.)
2013-10-13 01:16:30 +02:00
wm4 f312528ebc command: preferably show "add"/"cycle"/"set" command errors on OSD
Before this, they were shown on terminal only. Now they use the OSD
mechanism, which shows them on the video window or the terminal,
depending on settings and what's available.
2013-10-12 18:57:02 +02:00
wm4 20988ee607 command: don't allow changing volume if no audio initialized
Changing volume when audio is disabled was a feature request (github
issue #215), and was introduced with commit 327a779.

But trying to fix github issue #280 (volume is not correct in no-audio
mode, and if audio is re-enabled, the volume set in no-audio mode isn't
set), I concluded that it's not worth the trouble and the current
implementation is questionable all around. (For example, you can't
change the real volume in no-audio mode, even if the AO is open - this
could happen with gapless audio.) It's hard to get right, and the
current mixer code is already hilariously overcomplicated. (Virtually
all of mixer.c is an amalgamation of various obscure corner cases.)

So just remove this feature again.

Note that "options/volume" and "options/mute" still can be used in
idle mode to adjust the volume used next time, though these properties
can't be used during playback and thus not in audio-only mode.

Querying the volume still "works" in audio-only mode, though it can
return bogus values.
2013-10-12 18:57:02 +02:00
wm4 38874b2f2e playlist: check for NULL on caller site
Letting some playlist functions randomly accept NULL, while others do
not isn't such a good idea.
2013-10-12 18:57:02 +02:00
Philip Sequeira 7ce464bef9 options: --loop=N means playback N times, not N+1 times
The argument or this change is that --loop should set how often the
file is played, not the number of additional repeats.

Based on pull request 277, with additions to the manpage and removal
of "--loop=0".

Signed-off-by: wm4 <wm4@nowhere>
2013-10-12 18:57:02 +02:00
wm4 d1c473bc25 libquvi9: work around insane interaction between libquvi and libkdecore
The primary effect of this commit is that it fixes playback resume if
libquvi 0.9 and German locale are used, and libkdecore is on the system.
(See github issue #279.)

libquvi uses libproxy to determine system-wide proxy settings. libproxy
in turn loads libkdecore (if present) to determine KDE proxy settings.
libkdecore has a global constructor, which calls setlocale(LC_ALL, ""),
switching the current locale from "C" to what the user's settings. This
breaks some basic C string processing functions. Note that the locale
won't be set on program start, but only when libproxy calls dlopen() on
its config_kde module, which actually causes libkdecore to be loaded and
initialized.

In particular, with German locale, snprintf() would use "," instead of
"." when formatting float values, which in combination with playback
resume, would lead to parse errors the next time mpv was started, which
is how this issue was found.

I'd consider this a bug with libkdecore or at least libproxy. No library
should ever even touch locale: it might break basic expectations on C
string handling functions, might override program settings, and it's not
thread-safe. But this is so nasty and severe, that a quick hack to fix
it hurts less.

See github issue #279 and KDE bug #325902.
2013-10-12 18:56:03 +02:00
Mohammad Alsaleh 65a3977282 mpvcore/playlist.c: Avoid NULL reference in playlist_add_base_path()
Before this patch, those will cause a crash:

  mpv -playlist /dev/null
  mpv -playlist <(bla) # if the result of bla is empty

Signed-off-by: Mohammad Alsaleh <CE.Mohammad.AlSaleh@gmail.com>
Signed-off-by: Stefano Pigozzi <stefano.pigozzi@gmail.com>
2013-10-11 18:01:47 +02:00
Ben Boeckel 67eb187826 matroska: use memmove when collapsing the source list down 2013-10-08 22:00:23 -04:00