Commit Graph

49620 Commits

Author SHA1 Message Date
Wim Taymans c01bb44e36 ao_pipewire: don't access core after disconnect
pw_core_disconnect frees the core, so accessing it afterward to
destroy the context is not allowed.

Instead, just destroy the context, the first thing it does is disconnect
all cores for us.
2022-07-08 07:45:09 -07:00
Wim Taymans 60ed51008d ao_pipewire: zero listeners
The listeners need to be cleared because removing them might invoke the
removed handler, which could otherwise point to invalid memory.
2022-07-08 07:45:09 -07:00
Alex B d38ff1c958 ao_pipewire: support ao-volume on non-stereo channel layouts
mpv only remembers volume for two channels.
Always apply the same volume to all channels in case of
non-stereo layout similarly to ao_pulse.
Don't try to do anything smart when averaging volumes,
normally they are equal anyway.
2022-07-08 06:39:23 -07:00
hooke007 6858fc7d80 DOCS/encoding: remove the legacy option syntax 2022-07-07 21:12:57 -04:00
Ho Ming Shun 80e29d1851 drm_prime: fix newline in error message 2022-07-05 13:55:47 -04:00
J. Dekker 659ab2f946 meson: fix rst2html command 2022-07-05 13:19:42 +00:00
Dudemanguy 369168b9be context_x11egl: remove supposed transparency fix
This was introduced in 7fb972fd39 and
later revised in f5a094db04. Transparency
in EGL/X11 has been broken upstream for years in Mesa unfortunately.
However, the first commit claimed to have found a way to preserve
transparency by doing a trick with picking EGLConfigs (the second commit
revises this but keeps the logic in place). However, it doesn't appear
that the first commit actually fixes anything (transparency doesn't work
on my machine) and no one else seems to have reported it working. On the
other hand, if Mesa does ever actually fix this, transparency would
immediately be broken since mpv would always set the EGL_ALPHA_SIZE to
0. Go ahead and remove this since it doesn't seem to have any actual
utility and is technically a bit of a timebomb (not that deleting two
lines is a lot of work but still) if upstream ever does fix this.
2022-07-01 14:13:19 +00:00
25792431 beac0d729b DOCS: fix typo 2022-07-01 14:11:01 +00:00
dyphire 572850774d DOCS/osc: fix option "showidlescreen" -> "idlescreen"
This option was added in mpv-player@ec236f7, but its name in the document description is incorrect
2022-07-01 14:06:31 +00:00
Dudemanguy 8557ba76e2 meson: add a summary at the end of configuration
The meson build does a lot of checks and if you aren't familiar with the
internals of the meson.build, it may not be clear what is actually
enabled and what isn't. It turns out that meson has a handy function,
summary, exactly for this. This just prints a pretty summary of some
notable features in the build. It's not meant to be a comprehensive
list, but rather just what users are likely to care the most about (i.e.
x11, vulkan, etc.)
2022-06-27 19:09:33 +00:00
Niklas Haas 3a2838c88d vo_gpu_next: implement --cscale
Fixes #9451
2022-06-24 16:11:17 +02:00
Niklas Haas 8da6b355f8 swresample: don't forcibly clip on every conversion
This was introduced in 04257417 without a clear explanation of the bug
it was solving, so I have no idea if it's still needed (or why it ever
was). And it definitely creates unexpected behavior, e.g. forced
clipping when converting between float and floatp.

I therefore think we should simply remove this logic and see if it
regresses anything else, then fix those other bugs *properly* (if
they're still around).

Fixes #9979
2022-06-23 23:52:35 +02:00
Avi Halachmi (:avih) 3694af6076 js: key bindings: ensure priorities for same-key - again
Commit 7f4841ff sorted the bindings so that if the same key was bound
more than once, then the newest binding takes priority (sorted last).

However, it got the comparison function wrong, which means the result
of the sort depended on the algorithm and not on the actual data, so
the priority for keys with more than one binding was still arbitraty.

Fix the sort function, and finally ensure that later binding acutally
override earlier bindings of the same key.
2022-06-23 17:16:33 +03:00
Dudemanguy 652f09a7a6 x11: avoid XPresent API calls when it's not needed
This commit kind of mixes several related things together. The main
thing is to avoid calling any XPresent functions or internal functions
related to presentation when the feature is not auto-whitelisted or
enabled by the user. Internally rework this so it all works off of a
use_present bool (have_present is eliminated because having a non-zero
present_code covers exactly the same thing) and make sure it updates on
runtime. Finally, put some actual logging in here whenever XPresent is
enabled/disabled. Fixes #10326.
2022-06-22 18:09:11 +00:00
CogentRedTester 1ffdb9128d lua: command_native_async: make the callback optional
The documentation states that the callback is optional, but it actually
was not.

Now it's optional, as docuented.
2022-06-22 14:44:52 +03:00
CogentRedTester 099ae86717 lua: command_native_async: always callback a-sync
Previously if the raw command_native_async returned an error then the
callback function was run directly. This meant that script writers
potentially had to account for both synchronous and asynchronous logic
in the callback, which can happen even with seemingly 'safe' commands
if the mpv event queue is full.

This was at odds with the Javascript implementation of
the function, which always runs the callback asynchronously.

Now the mp.add_timeout function is used to run the callback
asynchronously on error, replicating the Javascript implementation.

This provides consistency for developers in how the callback is handled
in Lua, and increases consistency between the Lua and Javascript APIs.
2022-06-22 14:44:12 +03:00
Dudemanguy 24f4582b6f x11: add --x11-present option
With the recent addition of the libxpresent, it should improve frame
timings for most users. However, there were known cases of bad behavior
(Nvidia) which lead to a construction of a whitelist instead of just
enabling this all the time. Since there's no way to predict whatever
combination of hardware/drivers/etc. may work correctly, just give users
an option to switch the usage of xorg's presentation statistics on/off.
The default value, auto, works like before (basically, Mesa drivers and
no Nvidia are allowed), but now one can force it on/off if needed.
2022-06-22 03:55:49 +00:00
Dudemanguy d9f7dd7212 x11: add nouveau to the xpresent whitelist
A user noted that this worked correctly (i.e. vsync jitter of 0) so go
ahead and add it here as a safe driver for xpresent to use.
2022-06-22 03:55:49 +00:00
Dudemanguy 230d490eca x11: correct provider detection logic
The old logic always reset the x11->has_mesa/has_nvidia values on every
loop through the provider. This meant that it would always just match
whatever the last provider happened to be. So in the case of a dual GPU
system, if nvidia was the very first provider and the integrated
intel/amd card was the second (in practice, this is probably mostly the
other way around), then mpv would set has_mesa to true and has_nvidia to
false and thus try to use presentation. This is not the intended
behavior. Just rework this by also checking x11->has_mesa/has_nvidia in
the loop so a true value from the previous iteration is preserved.
2022-06-21 18:05:35 +00:00
Aaron Boxer b29878e3a1 vo_vaapi_wayland: remove vaapi format query as formats are never used
This code was taken from the older vo_vaapi driver, which does
use the vaapi format list, but the new driver has no use for
these formats, as it is only interested in va surfaces that
can be mapped to wl buffers. The format doesn't enter into
it at all.
2022-06-21 14:05:19 +00:00
Dudemanguy 45ff20986d meson: remove pointless d3d11 dictionary
Immediately after this, d3d11 is defined again and the rest of the
meson.build uses that. Probably, this dictionary was from the original
meson PR and removing it was forgotten at some point while stuff was
being rewritten.
2022-06-20 15:01:41 +00:00
Dudemanguy 2606d4cc51 x11: replace strcasestr usage with bstr
strcasestr is a GNU extension, but we can just use bstr instead to do
the same thing.
2022-06-19 16:21:07 -05:00
Dudemanguy 7e921e9939 github/workflows: install libxpresent on freebsd
This is needed for x11 which is in turn needed for vdpau.
2022-06-19 18:13:55 +00:00
Dudemanguy 3d459832a8 x11: support xorg present extension
This builds off of present_sync which was introduced in a previous
commit to support xorg's present extension in all of the X11 backends
(sans vdpau) in mpv. It turns out there is an Xpresent library that
integrates the xorg present extention with Xlib (which barely anyone
seems to use), so this can be added without too much trouble. The
workflow is to first setup the event by telling Xorg we would like to
receive PresentCompleteNotify (there are others in the extension but
this is the only one we really care about). After that, just call
XPresentNotifyMSC after every buffer swap with a target_msc of 0. Xorg
then returns the last presentation through its usual event loop and we
go ahead and use that information to update mpv's values for vsync
timing purposes. One theoretical weakness of this approach is that the
present event is put on the same queue as the rest of the XEvents. It
would be nicer for it be placed somewhere else so we could just wait
on that queue without having to deal with other possible events in
there. In theory, xcb could do that with special events, but it doesn't
really matter in practice.

Unsurprisingly, this doesn't work on NVIDIA. Well NVIDIA does actually
receive presentation events, but for whatever the calculations used make
timings worse which defeats the purpose. This works perfectly fine on
Mesa however. Utilizing the previous commit that detects Xrandr
providers, we can enable this mechanism for users that have both Mesa
and not NVIDIA (to avoid messing up anyone that has a switchable
graphics system or such). Patches welcome if anyone figures out how to
fix this on NVIDIA.

Unlike the EGL/GLX sync extensions, the present extension works with any
graphics API (good for vulkan since its timing extension has been in
development hell). NVIDIA also happens to have zero support for the
EGL/GLX sync extensions, so we can just remove it with no loss. Only
Xorg ever used it and other backends already have their own present
methods. vo_vdpau VO is a special case that has its own fancying timing
code in its flip_page. This presumably works well, and I have no way of
testing it so just leave it as it is.
2022-06-19 18:13:55 +00:00
Dudemanguy ceade34930 x11: use xrandr providers for driver detection
Unfortunately there's a certain company that makes graphics drivers that
are harder to deal with. The next commit aims to implement presentation,
but some empirical testing from users show that it's actually broken.
Give up and just tap into Xrandr so we can figure what drivers (or well,
providers by the extension terminology) are driving the screen.
Basically if we find intel, amd, or radeon, assume it's a Mesa driver.
If we find nvidia, then it must be nvidia. This detection requires randr
1.4 (which means using presentation in mpv secretly depends on randr
1.4), but this protocol version is nearly a decade old anyway so
probably 99.9% of users are fine. Do the version query check and all
that anyway just to be on the safe side.
2022-06-19 18:13:55 +00:00
Dudemanguy 7ce26dd324 vo: move wayland presentation to separate files
Wayland had some specific code that it used for implementing the
presentation time protocol. It turns out that xorg's present extension
is extremely similar, so it would be silly to duplicate this whole mess
again. Factor this out to separate, independent code and introduce the
mp_present struct which is used for handling the ust/msc values and some
other associated values. Also, add in some helper functions so all the
dirty details live specifically in present_sync. The only
wayland-specific part is actually obtaining ust/msc values. Since only
wayland or xorg are expected to use this, add a conditional to the build
that only adds this file when either one of those are present.

You may observe that sbc is completely omitted. This field existed in
wayland, but was completely unused (presentation time doesn't return
this). Xorg's present extension also doesn't use this so just get rid of
it all together. The actual calculation is slightly altered so it is
correct for our purposes. We want to get the presentation event of the
last frame that was just occured (this function executes right after the
buffer swap). The adjustment is to just remove the vsync_duration
subtraction. Also, The overly-complicated queue approach is removed.
This has no actual use in practice (on wayland or xorg). Presentation
statistics are only ever used after the immediate preceding swap to
update vsync timings or thrown away.
2022-06-19 18:13:55 +00:00
Dudemanguy 44ecf83a1b meson: use require when checking for vdpau
Technically this was wrong. If you passed -Dvdpau=enabled but did not
have x11 (a requirement for this), the build would silently just not
build the vdpau VO. The correct behavior is for it to be a hard error.
Accomplish this by using the require function and making sure that x11
is indeed being used before attempting to find the library.
2022-06-19 02:24:31 +00:00
Mia Herkt 07d78f8c8b
ci/build: Do not manually install Meson in openSUSE container
Newer image builds already include Meson.
2022-06-19 02:56:28 +02:00
Crend King c1a46ecfaf meson: rearrange library dependency order to avoid crash with fontconfig
In win32 build, if libass and libfontconfig appear after libmingwex
during linking, crash happens whenever fontconfig calls to opendir().

Moving them before ffmpeg makes sure they always appear first.

More info on https://github.com/shinchiro/mpv-winbuild-cmake/issues/217.
2022-06-18 15:17:46 +00:00
Aaron Boxer c961f4d0db vo_vaapi_wayland: only attach solid buffer once to main surface, on creation
There's no need to attach it with each frame.
2022-06-15 20:54:34 +00:00
Aaron Boxer ccce813a92 vo_vaapi_wayland: remove unnecessary subsurface sync/desync in resize
resize only changes subsurface position, which is always synchronized
with the parent surface.

For reference, see :
https://wayland-book.com/surfaces-in-depth/subsurfaces.html
2022-06-15 20:54:34 +00:00
Jan Ekström 1e1956e15b ci/build-mingw64: enable test building
Not currently run, but adds coverage for compiled code.
2022-06-15 21:19:10 +03:00
Jan Ekström 5d9af3a9dd ci/build-mingw64: bump dependencies 2022-06-15 21:19:10 +03:00
Jan Ekström 05a3affc58 ci/build-mingw64: switch to fossils directory for zlib
This contains current as well as previous versions, while the root
directory only contains the latest version.
2022-06-15 21:19:10 +03:00
Jan Ekström 312a555053 ci/build-tumbleweed: attempt to enable unit tests in CI 2022-06-15 21:19:10 +03:00
Jan Ekström 8f274da066 test/chmap: start adding AVChannelLayout unit tests
The first set iterates through all standard FFmpeg layouts and
checks that those which fit MP_NUM_CHANNELS succeed.

The second set iterates through built-in named channel layouts,
and attempts to convert them to AVChannelLayouts.
2022-06-15 21:19:10 +03:00
Jan Ekström 8123adadbd audio/chmap: add mp_iterate_builtin_layouts
Mostly useful for unit tests in order to access the channel
layouts from chmap which have mapped channels.
2022-06-15 21:19:10 +03:00
Jan Ekström 0411acf5f6 f_lavfi: switch to AVChannelLayout when available 2022-06-15 21:19:10 +03:00
Jan Ekström edfd17ab18 ad_lavc: switch to AVChannelLayout when available 2022-06-15 21:19:10 +03:00
Jan Ekström e7483ced5d af_lavcac3enc: switch to AVChannelLayout when available 2022-06-14 22:41:20 +03:00
Jan Ekström 42b58c5698 af_lavcac3enc: refactor chmap adding into its own function
This simplifies ifdeffery with AVChannelLayouts.
2022-06-14 22:19:45 +03:00
Jan Ekström 7a3f9af67f ao_lavc: switch to AVChannelLayout when available 2022-06-12 21:05:59 +03:00
Jan Ekström cfc39bec00 demux_lavf: switch to AVChannelLayout when available 2022-06-12 21:05:59 +03:00
Jan Ekström 46b19aedc6 common/av_common: switch to AVChannelLayout when available 2022-06-12 21:05:59 +03:00
Jan Ekström 302acb27c8 audio/aframe: switch to AVChannelLayout when available 2022-06-12 21:05:59 +03:00
Jan Ekström 1d15a5a059 audio: add AVChannelLayout helpers to convert from/to mp_chmap
This is the new FFmpeg channel layout structure, which now
combines channel count and layout into a single location.

Only unspecified (channel count only) and native (channel layout
mask based) layouts are currently supported for the initial move
towards non-deprecated APIs.
2022-06-12 21:05:59 +03:00
Dudemanguy 602995fd40 wayland: set appid before initial surface commit
This shouldn't have mattered but apparently qtile is unable to get the
app id if you set it after the initial surface commit. Wayland is a mess
anyway so just shuffle this around so that the frame callback and
surface commit are the last things registered in vo_wayland_init. This
works around qtile and, in theory, doesn't appear to break anything
else. Fixes #10280.
2022-06-11 10:20:06 -05:00
Dudemanguy b3ef506932 wayland_gl: fix a typo
Somehow in commit 661b5542de, my editor
snuck in a ¥ sign in here. Oops.
2022-06-11 10:07:11 -05:00
Dudemanguy 661b5542de wayland_gl: wait until resize to create egl_window
Some wayland compositors (i.e. weston) get extremely picky about
committed buffer sizes not matching the configured state. In particular,
weston throws an error on you if you attempt to launch with
--window-maximized and use opengl (vo_vaapi_wayland actually errors as
well in this case, but that's a different issue). The culprit here is
actually wl_egl_window_create. This creates an initial buffer at the
sizes passed in the arguments which is what weston doesn't like.
Instead, move the egl_window creation call to the resize function. This
ensures that mpv is using the size obtained via the toplevel event, and
it should always be the buffer size we want.
2022-06-10 13:55:22 +00:00
Sagnac aab9ab97f0 DOCS/options: fix incorrect labelling of hr-seek default
The `absolute` value was incorrectly labelled as the default instead of
the value named `default`, which was somewhat confusing. When the newer
default option was added in 679e410 it seems like wm4 forgot to remove
the label in the manual on the previous default.
2022-06-10 13:42:10 +00:00