0
0
mirror of https://github.com/mpv-player/mpv.git synced 2024-09-20 12:02:23 +02:00
Commit Graph

4765 Commits

Author SHA1 Message Date
nanahi
fea6adbc97 x11_common: handle runtime keepaspect/keepaspect-window change
On X11, aspect ratio constraint is applied on the window manager side,
so whenever keepaspect and keepaspect-window change, mpv should update
the size hint immediately, otherwise the new constraint isn't applied.
2024-07-12 20:19:11 +00:00
Kacper Michajłow
6c56a413ab win32: unregister window class on dll detach
Window classes are global per process, but they are associated with the
module that registered them. Documentation is clear that it is the DLL's
responsibility to unregister its own classes:

No window classes registered by a DLL are unregistered when the DLL is
unloaded. A DLL must explicitly unregister its classes when it is
unloaded.

See: https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-registerclassw

Using a window class after the DLL is unloaded would result in access
violation errors. This is not that important for libmpv, where it is
unlikely someone would use the "mpv" window class externally. The real
issue comes from the fact that reloading libmpv would fail to register
the class (as it still exists) and consequently fail to create a window.

This commit fixes the operability of libmpv after reloading it.

Fixes: #11638
2024-07-11 21:55:21 +02:00
Kacper Michajłow
d448598588 vo/opengl/context_win: fix crash on init failure
Don't try to access window context if it failed to create.
2024-07-11 21:55:21 +02:00
llyyr
14571f0f77 vo_dmabuf_wayland: don't use -ve margins in window size calculation
This happens with a positive --video-zoom value. We send invalid
toplevel size and get killed by the compositor.
2024-07-10 19:22:24 +00:00
llyyr
6c59b0272b wayland: use wl_list_empty instead of wl_list_length 2024-07-08 13:33:32 +00:00
llyyr
9d7d861202 wayland: bump wayland-protocol requirement to 1.31
And wayland-client/cursor to 1.21

Debian Stable has these
2024-07-08 13:33:32 +00:00
Dudemanguy
00f43e0916 wayland: fix missed int -> double conversion for cursor scaling
Client side cursors have always had some issues with fractional scaling.
However since we changed to using viewporter for cursor scaling, most
(or all?) of the problems can be fixed. Unfortunately, a scaling factor
was being truncated to int instead of kept as a double. This matched the
old behavior with buffer_scale, but it's better to use double so the
viewport is actually set to the correct size. Of course, none of this is
relevant if the compositor is using cursor shape.

Fixes f0a6578259
Fixes #14001
2024-07-06 09:03:40 -05:00
Guido Cella
dc523b137f video/out/gpu/context: convert --gpu-api to object settings list
This follows up 96e1f1dfa5 which converted --gpu-context, and has the
same advantages as listed there.

Unlike with --gpu-context auto can be used anywhere in the list, e.g.
--gpu-api=d3d11,auto works.

I wanted to use the list of GPU contexts as the description in
get_type_desc(), but there is no talloc context to allocate it to, so I
set a print_help_list to print them. The APIs go before the contexts so
that etc/_mpv.zsh doesn't try to complete the contexts.
2024-07-04 22:23:17 +00:00
Guido Cella
3f43999bd6 video/out/gpu/context: simplify --gpu-context's check_unknown_entry
This function is used to reject invalid context names early, and without
it the context fails to create and only audio is played, but it doesn't
need to check for known entries again.
2024-07-04 22:23:17 +00:00
Dudemanguy
68a1a3879c wayland: add a --wayland-present option
Mainly for debugging. It might be handy to disable presentation feedback
on wayland to make sure something isn't going wrong with the
calculations somewhere.
2024-06-28 03:33:16 +00:00
Dudemanguy
111571bd05 options: remove some options with .deprecation_message
In both cases, setting these options did nothing other than give you a
warning that they may be removed in the future. Remove them now.
2024-06-25 02:18:58 +00:00
Dudemanguy
4d7e440533 options: remove various OPT_REMOVED usage
Most of these are pretty obscure things that were replaced a long time
ago. The special messages they were printing are also not really useful
at all so just remove them.
2024-06-25 02:18:58 +00:00
Dudemanguy
6e3d90d72a options: remove some deprecated OPT_REPLACED option mapping
These were all deprecated in mpv 0.37.0 or earlier and are not
considered common enough options to warrant keeping the deprecated
mapping longer. Since demux_cue had only a single option in it, the
entire option substract is removed. This can be readded later if someone
wants to introduce a specific option to it again.
2024-06-25 02:18:58 +00:00
nanahi
265056fa54 vo_gpu: optimize pass_info_reset
No need to reset mp_pass_perf which is only read when desc.len > 0.
This avoids zeroing >16384 uint64_t's every time it's called.
Profiling shows that this reduces CPU usage for frame rendering by ~4%.
2024-06-22 22:48:40 +02:00
Kacper Michajłow
0d8f74231f misc/uuid: remove no longer needed vendored implementation 2024-06-22 16:12:14 +02:00
Kacper Michajłow
4ec060f946 vo_tct: clear backbuffer on reconfig
We were drawing garbage data after reconfig, if there is no video
frame ready or with --force-window without video track.

Found by OSS-Fuzz.
2024-06-22 00:50:38 +02:00
der richter
55241da4ad cocoa-cb: guard color spaces that are only available on 10.15.4 upwards 2024-06-18 19:30:07 +02:00
Kacper Michajłow
ab0a50874b d3d11: return minimum bitdepth for display output and swapchain
If the output display reports high bitdepth, 12-bit and 10-bit swapchain
is used the value returned from d3d11_color_depth needs to take it into
account.
2024-06-15 01:18:44 +02:00
Kacper Michajłow
b4bbc27d9c input: map Num 5 to distinct value when numlock is off
Until now both numlock on and off were mapped to KP5.
2024-06-13 20:42:24 +02:00
Misaki Kasumi
c55ff4176c opengl: add --egl-output-format 2024-06-08 10:23:32 +02:00
Misaki Kasumi
cd74f8f7c5 opengl: add --egl-config-id 2024-06-08 10:23:32 +02:00
Kacper Michajłow
dea176a7bf hwdec_vaapi: suppress comparision warning
comparison of unsigned expression in '< 0' is always false
2024-06-07 21:12:38 +02:00
nanahi
b2a4c0ce91 wayland_common: properly handle modifiers for keyboard enter keys
Wayland protocol only guarantees the delivery of modifier information after
the enter event. To handle it properly for keys pressed in the enter
event, save those keys for later processing in the modifier event.
2024-06-07 18:57:35 +00:00
Kacper Michajłow
8dd262ffa5 ra_d3d11: make cache header constant size regardless of the build
This makes cache entries compatible between 32-bit and 64-bit builds and
avoids issues with loading cache wrong.
2024-06-07 19:41:50 +02:00
Kacper Michajłow
965809f108 w32_common: stop IME initialization timer after first try
It will be set again on first key press, but no need to call IME api
every 250ms until any key is pressed.
2024-06-07 19:41:15 +02:00
Kacper Michajłow
b4683fd3d8 {x11_common,context_x11egl}: suppress Wundef warning 2024-06-05 19:07:58 +02:00
Kacper Michajłow
37127276cc win32: quantize taskbar playback position into uint8 range
Also, if the position is valid, set it to 1 / INF. Windows interprets 0
as non-progress.

Progress is quantized into uint8 range, it is good enough for this
use-case. This avoids unnecessary vo_control and
ITaskbarList3::SetProgressValue calls and should be visually
indistinguishable in practice.

Fixes #14282
2024-06-03 19:16:35 +02:00
Kacper Michajłow
d3b251bb99 Revert "d3d11: calc vsync interval on real stats, not just last interval"
The values provided since last disjoint event may include significant
error in case there are periods of slower presentation. We should look
at more localized/current values of presentation.

For more accurate approximation of vsync rate I plan to add better
algorithm to calculate it.

Revert this commit alone as it is not neccessary and gives as separation
from other changes for better regression testing.

This reverts commit f27767f59e.
2024-06-03 19:16:01 +02:00
Dudemanguy
52bdeb07a1 x11: correct position coordinates if mpv was launched with --fs
If mpv is launched with --fs, the x11 code tries to reset the size and
position of the window when the fullscreen exits. This has bad behavior
with multiple monitors because the saved nofsrc is not reliable in many
situations. Particularly if the window manager moves the fullscreen
window somewhere else while mpv is fullscreen. The result will be that
exiting fullscreen always goes back to screen 0.

Fix this by translating the rc coordinates of the nofsrc rc to the new
monitor when we're leaving fullscreen from an initial --fs case. By
giving get_current_display a specific rc, we can return what xrandr
display the coordinates are associated with and decide if the nofsrc
should be translated to its new location. After that bit of math, the
usual move/resize logic takes care of the rest but this time it actually
works off of the correct position. Fixes #14226.
2024-05-29 13:39:20 +00:00
llyyr
7ff6cf807c vo_vaapi: remove redundant function call
we already free video specifics when reconfiguring
2024-05-28 21:29:07 +02:00
llyyr
0aec73d1bf vo_vaapi: fix use-after-free when quitting
p->output_surfaces gets freed by destroy_frame when quitting
2024-05-28 21:29:07 +02:00
llyyr
ff73aeb5c3 vo_vaapi: fix use-after-free of current frame
This was forgotten when switching vo_vaapi from using draw_image to
draw_frame API

Fixes: 0b70598358 ("vo: fully replace draw_image with draw_frame")
2024-05-28 21:29:07 +02:00
nanahi
2fa66b850d wayland_common: ignore unknown key states
Once https://gitlab.freedesktop.org/wayland/wayland/-/merge_requests/368
is merged and we upgrade wl_seat version to 10, compositors will also
generate "repeated" events, which mpv treats as key up right now.
Change the check so that unknown key states are ignored.
2024-05-24 17:57:55 +00:00
nanahi
0fcfbab9af wayland_common: handle pressed keys in keyboard_enter event
This is required by the wayland protocol to keep the logical keyboard
state consistent.
Quoting 9e4f256927:

> In the wl_keyboard logical state, this event sets the active surface to
> the surface argument and the keys currently logically down to the keys
> in the keys argument.
2024-05-24 17:57:55 +00:00
Dudemanguy
1e1e365c18 wayland: use wl->callback_surface for idle inhibitor creation
The idle inhibit protocol specifies that the compositor may ignore the
idle inhibitor if the surface is occluded. In the case of
vo_dmabuf_wayland, wl->surface corresponds to typical black bars when
the video aspect ratio is different than the display's. So in many
cases, wl->surface is actually occluded by wl->video_surface which sits
above it. Change this so that the idle inhibitor is created on
wl->callback_surface instead which is either wl->surface for the gpu VOs
or wl->video_surface for vo_dmabuf_wayland. Fixes #14206.
2024-05-22 14:08:01 +00:00
Dudemanguy
2c68e6cb1f wayland: also log version numbers with protocol interface names
Might be useful for debugging.
2024-05-19 00:05:48 +00:00
Dudemanguy
47f60d1c52 wayland: cap xdg_wm_base at 4 if wm_capabilities aren't supported
Fixes #13986.
2024-05-16 16:23:18 +00:00
Kacper Michajłow
3874145248 hwdec_cuda_vk: add missing io.h include
Fixes compilation on Windows with cuda enabled.
2024-05-11 21:34:24 +02:00
Kacper Michajłow
f17ad792c6 vo_gpu_next: check if existing cache file has correct size 2024-05-10 22:54:25 +02:00
Kacper Michajłow
e175b3f685 lcms: check for null arg in gl_parse_3dlut_size
This fixes `icc-3dlut-size` validation in config which would crash if
set without argument.

Found by OSS-Fuzz.
2024-05-09 21:21:40 +02:00
Kacper Michajłow
325abfeed7 dmabuf: fix warnings on 320-bit build 2024-05-08 18:52:40 +02:00
Kacper Michajłow
43b702d707 drm_prime: remove off by one when allocating new ref counter 2024-05-07 21:05:18 +02:00
repojohnray
d1e55a0e87 drm_prime: fix issue detected by valgrind
Conditional jump or move depends on uninitialised value(s)
   at 0x10FE22: drm_prime_remove_handle_ref (drm_prime.c:144)
   by 0x10FCCD: drm_prime_destroy_framebuffer (drm_prime.c:107)
   by 0x10FEB1: set_current_frame (hwdec_drmprime_drm.c:73)
   by 0x11054F: overlay_frame (hwdec_drmprime_drm.c:223)
   by 0xF1311: gl_video_render_frame (video.c:3315)
   by 0xFA015: draw_frame (vo_gpu.c:85)
   by 0xF8FDB: render_frame (vo.c:961)
   by 0xF943F: vo_thread (vo.c:1099)
   by 0x5EBE89B: start_thread (in /lib/libpthread-2.31.so)
 Uninitialised value was created by a heap allocation
   at 0x484713C: realloc (vg_replace_malloc.c:1437)
   by 0x10258B: ta_realloc_size (ta.c:195)
   by 0x10325D: ta_xrealloc_size (ta_utils.c:298)
   by 0x10FDBF: drm_prime_add_handle_ref (drm_prime.c:133)
   by 0x10FC57: drm_prime_create_framebuffer (drm_prime.c:87)
   by 0x1102FF: overlay_frame (hwdec_drmprime_drm.c:188)
   by 0xF1311: gl_video_render_frame (video.c:3315)
   by 0xFA015: draw_frame (vo_gpu.c:85)
   by 0xF8FDB: render_frame (vo.c:961)
   by 0xF943F: vo_thread (vo.c:1099)
   by 0x5EBE89B: start_thread (in /lib/libpthread-2.31.so)

Conditional jump or move depends on uninitialised value(s)
   at 0x10FCE4: drm_prime_destroy_framebuffer (drm_prime.c:109)
   by 0x10FEB1: set_current_frame (hwdec_drmprime_drm.c:73)
   by 0x11054F: overlay_frame (hwdec_drmprime_drm.c:223)
   by 0xF1311: gl_video_render_frame (video.c:3315)
   by 0xFA015: draw_frame (vo_gpu.c:85)
   by 0xF8FDB: render_frame (vo.c:961)
   by 0xF943F: vo_thread (vo.c:1099)
   by 0x5EBE89B: start_thread (in /lib/libpthread-2.31.so)
 Uninitialised value was created by a heap allocation
   at 0x484713C: realloc (vg_replace_malloc.c:1437)
   by 0x10258B: ta_realloc_size (ta.c:195)
   by 0x10325D: ta_xrealloc_size (ta_utils.c:298)
   by 0x10FDBF: drm_prime_add_handle_ref (drm_prime.c:133)
   by 0x10FC57: drm_prime_create_framebuffer (drm_prime.c:87)
   by 0x1102FF: overlay_frame (hwdec_drmprime_drm.c:188)
   by 0xF1311: gl_video_render_frame (video.c:3315)
   by 0xFA015: draw_frame (vo_gpu.c:85)
   by 0xF8FDB: render_frame (vo.c:961)
   by 0xF943F: vo_thread (vo.c:1099)
   by 0x5EBE89B: start_thread (in /lib/libpthread-2.31.so)
2024-05-07 21:05:18 +02:00
nanahi
4e59a56896 various: fix comma style 2024-05-07 11:23:08 +02:00
nanahi
9f5edd4eed various: fix indentation 2024-05-07 11:23:08 +02:00
Jrelvas
1759d73c83 hwdec_cuda: reduce nesting in check functions
This simplifies the code and makes it easier to read.
2024-05-07 00:34:46 +02:00
Jrelvas
58f50c8e49 hwdec_cuda: avoid gpu wakeup by deferring cuInit
`cuInit` wakes up the nvidia dgpu on nvidia laptops. This is bad news because the wake up process
is blocking and takes a few seconds. It also needlessly increases power consumption.

Sometimes, a VO loads several hwdecs (like `dmabuf_wayland`). When `cuda` is loaded, it calls
`cuInit` before running all interop inits. However, the first checks in the interops do not
require cuda initialization, so we only need to call `cuInit` after those checks.

This commit splits the interop `init` function into `check` and `init`. `check` can be called without
initializing the Cuda backend, so cuInit is only called *after* the first interop check.

With these changes, there's no cuda initialization if no OpenGL/Vulkan backend is available. This prevents
`dmabuf_wayland` and other VOs which automatically load cuda from waking up the nvidia dgpu unnecessarily,
making them start faster and decreasing power consumption on laptops.

Fixes: https://github.com/mpv-player/mpv/issues/13668
2024-05-07 00:34:46 +02:00
Kacper Michajłow
b647201795 osdep/dirent: add implementation for Windows SDK build 2024-05-06 22:01:17 +02:00
Kacper Michajłow
fffe723fc4 various: move strings.h inclusion to common.h 2024-05-06 22:01:17 +02:00
Kacper Michajłow
18ef834ef4 various: move unistd.h inclusion to common.h 2024-05-06 22:01:17 +02:00