Commit Graph

48435 Commits

Author SHA1 Message Date
Jan Ekström 33519d61aa wayland: simplify mouse wheel direction calculation
Based on an idea by sfan5. Remove abs usage, and instead just
check for negative value, and set variable to either +/-1.
2020-03-19 20:27:55 +00:00
Kevin Mitchell 3aad89829f ao_wasapi: try mix format except for chmap
In shared mode, we previously tried to feed the full native format to
IsFormatSupported in the hopes that the "closest match" returned was
actually that.

Turns out, IsFormatSupported will always return the mix format if we
don't use the mix format's sample rate. This will also clobber our
choice of channel map with the mix format channel map even if our
desired channel map is supported due to surround emulation.

The solution is to not bother trying to use anything other than the mix
format sample rate. While we're at it, we might as well use the mix
format PCM sample format (always float32) since this conversion will
happen anyway and may avoid unecessary dithering to intermediate
integer formats if we are already resampling or channel mixing.
2020-03-19 20:39:44 +02:00
Kevin Mitchell 609d0ef478 ao_wasapi: handle S_FALSE in mp_format_res_str
IsFormatSupported may return S_FALSE (considered SUCCESS) if the
requested format is not suppported, but is close to one that is.
2020-03-19 20:39:44 +02:00
wm4 433c9a90a5 win32: pthread: define PTHREAD_MUTEX_ERRORCHECK
mpv uses it now. Doesn't need to do anything.
2020-03-19 00:11:23 +01:00
wm4 0b9ed9c274 build: make libass non-optional
Using mpv without libass isn't really supported, since it's not only
used to display ASS subtitles, but all text subtitles, and even OSD.

At least 1 user complained that the player printed a warning if built
without libass. Avoid trying to create the impression that using this
software without libass is in any way supported or desirable, and make
it fully mandatory.

(As far as making dependencies optional goes, I'd rather make ffmpeg
optional, which is an oversized and bloated library, rather than
something tiny like libass.)
2020-03-18 22:45:59 +01:00
wm4 cb82cbbbae osdep: add a pthread debugging wrapper
Because pthread failures are virtually undebuggable (which sure is
pretty strange, given all these heavy instrumentation tools these days).

Of course it affects only files which include osdep/threads.h.

I'm departing from the usual way to add symbols with config.h and using
"#if", and defining it on the compiler command line + "#ifdef" because I
don't want to include config.h from a header (which would be necessary
in this case) to keep things slightly cleaner. Maybe this is misguided,
but still.

This would have been easier if mpv defined its own wrappers for all
thread functions. But we don't (which to be honest is probably better
than e.g. going crazy like VLC and essentially reimplementing
everything). This seems to be a good compromise. Since it's off by
default and basically a developer tool, the minor undefined behavior
(redefining reserved symbols) isn't much of an issue.
2020-03-18 22:42:13 +01:00
wm4 373dad9962 f_decoder_wrapper: fix use of destroyed mutex
After calling the main filter's destroy callback, all child filters are
destroyed. But one of them still tried to access the cache_lock mutex
(which is destroyed in said destroy callback). This actually caused a
crash on Android with _FORTIFY_SOURCE.

Fix this by destroying the child filters first.
2020-03-18 22:31:17 +01:00
wm4 41e96d8b6b options: fix OPT_BYTE_SIZE upper limits
As an unfortunate disaster, min/max values use the type double, which
causes tons of issues with int64_t types. Anyway, OPT_BYTE_SIZE is often
used as maximum for size_t quantities, which can have a size different
from (u)int64_t.

OPT_BYTE_SIZE still uses in64_t, because in theory, you could use it for
file sizes. (demux.c would for example be capable of caching more than
2GB on 32 bit platforms if a file cache is used. Though for some reason
the accounting code still uses size_t, so that use case is broken. But
still insist that it _could_ be used this way.)

There were various inconsistent attempts to set m_option.max to a value
such that the size_t/int64_t upper limit is not exceeded. Due to the
double max field, this didn't really work correctly. Try to fix this
with the M_MAX_MEM_BYTES constant. It's a good approximation, because on
32 bit it should allow 2GB (untested, also would probably exhaust
address space in practice but whatever), and something "high enough" in
64 bit.

For some reason, clang 11 still warns. But I think this might be a clang
bug, or I'm crazy. The result is correct anyway.
2020-03-18 20:51:38 +01:00
wm4 a550bf4927 demux_mkv: fix another integer/float conversion warning
This code could assign INT64_MAX+1 (as double) to int64_t.
2020-03-18 20:44:54 +01:00
wm4 f73db96077 client API: fix MPV_FORMAT_DOUBLE => MPV_FORMAT_INT64
(Why can it do this conversion at all? This is  shitshow anyway.)
2020-03-18 20:43:56 +01:00
wm4 5a81de59a8 m_option: attempt to fix two rounding issues
Since double has a mantissa too small to hold INT64_MAX in full
precision, converting INT64_MAX to double rounds up. Insert some casts
to silence corresponding warnings (as shown by clang 11).

Also, the comparison in multiply_int64() was incorrect (I think...),
because if v==(double)INT64_MAX, then v==(1<<64), which cannot be
represented as int64_t.

There are probably better ways to solve this.
2020-03-18 20:19:13 +01:00
wm4 26f4f18c06 options: change option macros and all option declarations
Change all OPT_* macros such that they don't define the entire m_option
initializer, and instead expand only to a part of it, which sets certain
fields. This requires changing almost every option declaration, because
they all use these macros. A declaration now always starts with

   {"name", ...

followed by designated initializers only (possibly wrapped in macros).
The OPT_* macros now initialize the .offset and .type fields only,
sometimes also .priv and others.

I think this change makes the option macros less tricky. The old code
had to stuff everything into macro arguments (and attempted to allow
setting arbitrary fields by letting the user pass designated
initializers in the vararg parts). Some of this was made messy due to
C99 and C11 not allowing 0-sized varargs with ',' removal. It's also
possible that this change is pointless, other than cosmetic preferences.

Not too happy about some things. For example, the OPT_CHOICE()
indentation I applied looks a bit ugly.

Much of this change was done with regex search&replace, but some places
required manual editing. In particular, code in "obscure" areas (which I
didn't include in compilation) might be broken now.

In wayland_common.c the author of some option declarations confused the
flags parameter with the default value (though the default value was
also properly set below). I fixed this with this change.
2020-03-18 19:52:01 +01:00
Dudemanguy cdd6eb0994 wayland: notify vo if an output changes
Previously, the vo wasn't always informed if something about the output
changed during playback. For instance, changing a display's refresh rate
during playback would not update mpv's display fps. Fix this by simply
using VO_EVENT_WIN_STATE in output_handle_done which executes whenever
something about the output is changed.
2020-03-15 12:42:33 -05:00
wm4 281f5c63c1 m_option: remove debug code
Forgot to remove this. Here you see my confusion and realization how
casting INT64_MAX to double becomes INT64_MAX+1 (due to mantissa
precision and rounding), so some things seemed not to make sense at
first.
2020-03-14 19:08:47 +01:00
Avi Halachmi (:avih) 8861bfa913 vo_gpu: warn if correct-downscaling is ignored
And document that it's ignored with bilinear scaler.
2020-03-14 19:47:12 +02:00
wm4 cb2b5553bf osc: fix updating message when paused
The message_timeout field was basically polled. But ever since the OSC
was changed to work more event based, this didn't quite work. It was
quite visible when switching subtitle or audio tracks while paused (and
with caching disabled, since the cache update triggered some extra
redrawing).

Fix by using a proper timer.

I noticed that changing tracks with the message call commented didn't
redraw properly either, but, uh, I guess the message is always triggered
anyway, and happens to take care of this.
2020-03-14 15:15:44 +01:00
der richter ea13ec6d98 github: additionally ask for log files on build problems and questions 2020-03-14 14:16:31 +01:00
wm4 9d04e76f3f ao_pcm: fix double free on exit
This seems to be an older bug. It set priv->outputfilename to a new
talloc-allocated string, but the field is also managed as string option,
so talloc will free it first, then m_option_free() is called on the
dangling pointer. Possibly this is caused by the earlier ta destruction
order change.
2020-03-14 13:50:04 +01:00
der richter cd22e93fee cocoa-cb: support maximize/minimize on startup
Allow the --window-maximized and --window-minimized flags to actually
work when the player is started. since macOS doesn't like using both at
the same time the minimized state takes precedence over the maximized
state.
2020-03-14 12:23:42 +01:00
wm4 c784820454 options: introduce bool option type, use it for --fullscreen
The option code is very old and was added to MPlayer in the early 2000s,
when C99 was still new. MPlayer did not use the "bool" type anywhere,l
and the logical option equivalent to bool, the "flag" option type, used
int, with the convention that only the values 0 and 1 are allowed.

mpv may have hammered many, many additional tentacles to the option
code, but some of the basics never changed, and m_option_type_flag still
uses int. This seems a bit weird, since mpv uses bool for booleans. So
finally introduce an m_option_type_bool. To avoid duplicating too much
code, change the flag code to bool, and "reimplement" m_option_type_flag
on top of m_option_type_bool.

As a "demonstration", change the --fullscreen option to this new type.
Ideally, all options would be changed too bool, and m_option_type_flag
would be removed. But that is a lot of monotonous thankless work, so I'm
not doing it, and making it a painful years long transition.

At the same time, I'm introducing a new concept for option declarations.
Instead of OPT_BOOL(), which define the full m_option struct contents,
there's OPTF_BOOL(), which only takes the option field name itself. The
name is provided via a normal struct field initializer. Other fields
(such as flags) can be provided via designated initializers.

The advantage of this is that we don't need tons of nested vararg
macros. We also don't need to deal with 0-sized varargs being a pain
(and in fact they are not a thing in standard C99 and probably C11).
There is no need to provide a mandatory flags argument either, which is
the reason why so many OPT_ macros are used with a "0" argument. (The
flag argument seems to confuse other developers; they either don't
immediately recognize what it is, and sometimes it's supposed to be the
option's default value.)

Not having to mess with the flag argument in such option macros is also
a reason for the removal of M_OPT_RANGE etc., for the better or worse.

The only place that special-cased the _flag option type was in
command.c; change it to use something effectively very similar that
automatically includes the new _bool option type. Everything else should
be transparent to the change. The fullscreen option change should be
transparent too, as C99 bool is basically an integer type that is
clamped to 0/1 (except in Swift, Swift sucks).
2020-03-14 02:23:38 +01:00
wm4 7c4a550c0e DOCS/interface-changes.rst: add note about property notification changes
Commits ba70b150fb and 8a4f812b76 should have mentioned this. These
things should be quite useful for client API users, and thus should be
mentioned in a prominent place.

Although I'm not sure if anyone will understand from this gibberish what
this really means.
2020-03-14 01:40:54 +01:00
wm4 314a4a572b command: disable edition switching if there are no editions
Commit 8d965a1bfb changed option/property min/max handling. As a
consequence, ranges that contain only 1 or 0 elements are not possible
anymore. Normally that's fine, because it makes no sense to have an
option that has only one or none allowed value (statically).

But edition switching used some sort of mechanism where the property can
return a different, dynamically decided range at runtime. That meant
that if there were <2 editions, edition switching with the "cycle"
command would always pick the same value. But with the recent commit,
this changed to having "no range set" and would cycle through all
integer values.

Work this around with a simple change. Now, edition switching on a file
without editions shows "edition: auto" instead of "edition: 0", which
may appear odd. But the former is the --edition default value, and
previous mpv versions rendered the edition property like this when not
using switching.

(Who the fuck uses editions?)
2020-03-14 01:32:27 +01:00
wm4 8d965a1bfb options: change how option range min/max is handled
Before this commit, option declarations used M_OPT_MIN/M_OPT_MAX (and
some other identifiers based on these) to signal whether an option had
min/max values. Remove these flags, and make it use a range implicitly
on the condition if min<max is true.

This requires care in all cases when only M_OPT_MIN or M_OPT_MAX were
set (instead of both). Generally, the commit replaces all these
instances with using DBL_MAX/DBL_MIN for the "unset" part of the range.

This also happens to fix some cases where you could pass over-large
values to integer options, which were silently truncated, but now cause
an error.

This commit has some higher potential for regressions.
2020-03-13 17:34:46 +01:00
wm4 5d5a7e1953 ao_lavc: don't spam underrun warnings
Like ao_pcm, this is (conceptually) in perpetual underrun, as long as
dumping is fast enough.
2020-03-13 16:50:27 +01:00
wm4 28de668173 options: more pushing code around
Try to remove m_config implementation details from m_config_frontend.
Not sure if I like it. Seems to be ~100 lines of awkward code more, and
not much is gained from it. Also it took way too long to do it, and
there might be bugs.
2020-03-13 16:50:27 +01:00
wm4 eb381cbd4b options: split m_config.c/h
Move the "old" mostly command line parsing and option management related
code to m_config_frontend.c/h. Move the the code that enables other part
of the player to access options to m_config_core.c/h. "frontend" is out
of lack of creativity for a better name.

Unfortunately, the separation isn't quite clean yet. m_config_frontend.c
still references some m_config_core.c implementation details, and
m_config_new() is even left in m_config_core.c for now. There some odd
functions that should be removed as well (marked as "Bad functions").
Fixing these things requires more changes and will be done separately.

struct m_config is left with the current name to reduce diff noise.
Also, since there are a _lot_ source files that include m_config.h, add
a replacement m_config.h that "redirects" to m_config_core.h.
2020-03-13 16:50:27 +01:00
wm4 d3ad4e2308 options: remove intpair option type
This was mostly unused, and has certain problems. Just get rid of it.

It was still used in CDDA (--cdda-span) and a debug option for OpenGL
(--opengl-check-pattern). Replace both of these with 2 options, where
each sets the start/end values of the former span. Both were
undocumented somehow (normally we require all options to be documented),
so I'm not caring about compatibility, and not bothering to add it to
the API changelog.
2020-03-13 16:50:27 +01:00
wm4 3006c4ba5d options: remove min/max support from strings and string lists
We don't really use this anymore. Only --playlist and vf_lavfi filter
names did (to error on empty parameters), but it doesn't really matter.
2020-03-13 16:50:27 +01:00
wm4 06718da79c build: make C11 atomics mandatory
The emulation is pretty bad, and C11 compilers are everywhere now. It's
time to retire the emulation, which was always meant as temporary hack
for transition.

In theory, a user can still use --disable-stdatomic to enable the
emulation code, but that's sort of hidden. Actual support will be
removed after the next release or so.
2020-03-13 13:47:11 +01:00
Aman Gupta 5105a3b05a video/out/android_common: use jni helpers
Signed-off-by: Aman Gupta <aman@tmm1.net>
2020-03-12 22:08:25 +01:00
Niklas Haas c05e5d9d78 vo_gpu: generally allow non-storable FBOs
We have this cap now thanks to e2976e662, but we don't actually make
sure our FBOs are storable before we blindly attempt using them with
compute shaders.

There's no more need to unconditionally set `storage_dst = true` as long
as we make sure to include an extra condition on the `fbo_format`
selection to prevent users from accidentally enabling
compute-shader-only features with non-storable FBOs, alongside some
other miscellaneous adjustments to eliminate instances of "assumed
storability" from vo_gpu.
2020-03-08 21:41:16 +01:00
Niklas Haas c145c80085 vo_gpu: avoid error spam when ra_fbo fmt is non-storable
This simply makes the "is the destination FBO format bad?" check a tiny
bit less awful, by making sure we prefer storable FBO formats over
non-storable FBO formats. I'd love to make this also conditional on
whether or not we actually *need* a storable FBO format, but that logic
is decided later, in `pass_draw_to_screen`, and I don't want to
replicate the logic.

Fixes #7017.
2020-03-08 21:32:06 +01:00
wm4 3b4641a5a9 filter: minor cosmetic naming issue
Just putting some more lipstick on the pig, maybe it looks a bit nicer
now.
2020-03-08 19:38:10 +01:00
wm4 048334c396 command: add libass-version property
A bit of a mess with that ifdeffery, but fuck it.
2020-03-08 19:38:10 +01:00
wm4 6bf086fc15 sub: log libass version
Sometimes helpful. Would be even nicer if libass logged it themselves,
including git hash, I guess.
2020-03-08 19:38:10 +01:00
wm4 62c1d79724 player: rearrange libav* library check
No need to be nice. Also hopefully breaks idiotic distro patches.
2020-03-08 19:38:10 +01:00
wm4 d0d9ace421 stream_file: mark fd protocols as "unsafe"
Whatever good or bad that might do. In any case, they can easily trigger
UB-like behavior.
2020-03-08 19:38:10 +01:00
Dudemanguy 7170910f4c wayland: always use the fs-screen id for fs
Previously if the --fs-screen option was set, it would only use the
screen if mpv was launched with --fs and only on startup. During
runtime, the toggle would ignore it. Rework the logic here so that mpv's
fullscreen always uses --fs-screen if it is set. Additionally, cleanup
some unneeded cruft in vo_wayland_reconfig and make find_output more
useful.
2020-03-08 16:08:29 +00:00
wm4 28ea1ed296 stream_lavf: use smb:// for ffmpeg libsmbclient support
If you really want that, you can get it through FFmpeg, I guess.
2020-03-07 13:55:20 +01:00
wm4 3471476f3f ci: remove libsmblient
This was forgotten.
2020-03-07 13:53:56 +01:00
wm4 5524ba9d47 player: move on_unload hook after frame step pausing
Really minor detail that doesn't really matter. If frame stepping pauses
playback on end (why does this special case even exist), it should
probably be done after on_unload, because all works is supposed to be
finished at that point.
2020-03-07 12:47:46 +01:00
wm4 a56d5bdb53 client API: always reset new_property_events fields
This was not reset in the num_properties==0 case. This didn't really
matter, but for debugging it's slightly nicer to see new_property_events
reset once the client thread is done with it.
2020-03-07 12:47:46 +01:00
wm4 7f1bd0f30b manpage: explicitly mention "tick" event as deprecated
Just. Don't. Use. It.
2020-03-07 12:47:46 +01:00
wm4 d6f282e162 demux: bump --cache-secs default value
Change to it 1000 hours, which is "infinite" enough. (Hesitant to use
INFINITY, as that is not in the option's range. The option parser
rejects it because it causes only problems in API users and so on.)
2020-03-07 12:47:46 +01:00
wm4 f20dfef880 demux: mark recently added debug option as deprecated
It was the intention to remove it again after a release or two; mark it
was deprecated so nobody thinks it gets to stay.
2020-03-07 12:47:46 +01:00
Avi Halachmi (:avih) a23869379c js: osd-overlay update: return the command result (match 7a76b577)
Currently only useful for the new 'compute_bounds' command key.
2020-03-07 12:37:35 +02:00
Avi Halachmi (:avih) 9cf45d8300 js: osd-overlay update: support arbitrary key names
Until now the 'update' method used mp.command_native with a hardcoded
list of key names.

Change it to use whatever keys the user set to this object, so that
we can remain oblivious to new keys which 'osd-overlay' may support.

This is how the lua code did it from the begining. We didn't, and now
we pay the price.

Note: could be implemented either as we have now (clone `this`
excluding the methods) or by moving the methods up the prototype chain
(i.e. class methods) so they don't get enumerated and use `this` as
the command object itself.

However, in the latter approach we'll have to save the values which we
change (name, res_x, res_y) and restore them after the command, so it's
simpler to just clone `this`.
2020-03-07 12:37:35 +02:00
wm4 ba70b150fb client API: provide ways to finish property changes on file changes
When the current file changes (or rather, when starting/finishing
playback of a playlist entry), clients tend to have the problem that
it's hard to tell whether a property change notification (via
mpv_observe_property() and mechanisms layered on top of it) is from the
previous or new playlist entry. The previous commit probably helps, but
all the asynchronity is still a bit unhelpful.

Try to make this better by adding new hooks, that are run before/after
playback init/deinit. This is similar to the existing hooks, except
they're outside of "initialized" playback, which excludes that you might
accidentally get an overlap between the current and the previous/next
playlist entry.

That still doesn't seem quite enough, since normally, property change
notifications come after the hook event. So basically a client would
have to explicitly "drain" the event queue within the hook, and make the
hook continue only after that is done. Knowing when property
notifications are done is another asynchronous nightmare (how exactly it
works keeps changing within client.c, and an API user probably can't
tell anymore when all pending properties are truly done). So introduce
another guarantee: properties that were changed before the hook happens
will be returned before the hook event is returned. That means the
client will have received all pending property notifications from the
previous playlist entry (or whatever) before the hook is entered.

As another minor complication, we shouldn't just keep the hook pending
until _all_ property notifications are done, since the client's hook
could produce new ones. (Or just consider things like the demuxer thread
hammering the client with cache update events, while the "on_preloaded"
hook is run.) So there is some extra untested, fragile logic in client.c
to handle this (the waiting_for_hook flag).

This probably works, but was barely tested. Not sure if this helps
anyone, but I think it's fine for my own purposes. (I really hated this
aspect of the API whenever I used it myself.)
2020-03-07 02:52:10 +01:00
wm4 8a4f812b76 client API: avoid returning stale value on property notifications
This could happen if a property was flagged as changed, then updated,
then flagged again, but gen_property_change_event() was called before
the value was updated a second time. Then the function simply returned
the old value, and would later trigger a new change event again.

This was considered acceptable before, since property notifications are
asynchronous anyway (so they may always be "outdated", it just mattered
whether the most recent value was eventually delivered).

But consider ordering with events. It seems desirable that specific
important events (e.g. MPV_EVENT_START_FILE) should not be followed by
property updates that happened before it, because that would make
application logic really a mess, and property notification near-useless
in certain cases.

Avoid this by never returning a value if it was marked changed, but not
updated yet.

Unfortunately, this could lead to clients never receiving a value (or
receiving it with a high random delay), if they're too slow to read it
(or the property simply updates too often). Note that this is done for
_all_ property notifications, not just returned events. Hopefully not a
problem in practice. If it turns out to be one, this mechanism could be
restricted to actually returned events, for which this really matters.
2020-03-06 23:59:21 +01:00
wm4 575197ff8b client API: remove deprecated qthelper.hpp header
No replacement. Qt or C++ code has no business in this repository, and
new code (even if it uses Qt) should not use it. Get rid of it.

We consider the libmpv API itself as stable. Symbols can be deprecated,
but not be removed. However, qthelper.hpp was never considered part of
the libmpv API. There no ABI implications either, since it's a header-
only implementation that uses C API symbols only. It's just a header
provided for convenience for Qt/C++ programs (i.e. extremely limited
usefulness).
2020-03-06 19:37:44 +01:00