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

4735 Commits

Author SHA1 Message Date
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
der richter
8a61929eb8 cocoa-cb: add support for macOS color space transformation (EDR/HDR)
by default utilises the color space of the screen on which the window is
located. if a specific value is defined, it will instead be utilised.

depending on the chosen color space the macOS EDR (HDR) support is
activated and that OS's transformation (tone mapping) is used.

Fixes #7341
2024-05-05 19:02:50 +02:00
Kacper Michajłow
4cc9e6f999 win32: fix maximize state with --border=no
WS_POPUP windows cannot be maximized, so instead of forcing it with
unavoidable side-effects, change the window style before maximizing to
make it work correctly.
2024-05-05 14:02:57 +02:00
nanahi
861908c70f win32: make context menu items accessible from the window menu
This makes the context menu items accessible from the window menu,
which can be opened by either right-clicking on the title bar or
left-clicking on the mpv icon on the title bar.
2024-05-03 16:36:02 +02:00
nanahi
ee2e14015d win32: move context menu init/uninit to GUI thread
Currently if VO init fails, the context menu is leaked. Additionally,
init/uninit are in the VO thread, while other accesses are in the GUI
thread.

Fix this by moving them to the GUI thread, similar to other resources.
This also lets init function take the mpv HWND in the next commit.
2024-05-03 16:36:02 +02:00
Dudemanguy
cb613ba916 wayland: set wl->scaling if there is no wl->current_output yet
If we get either preferred_scale or preferred_buffer_scale this early
during initialization the wl->scaling value should be immediately
updated instead of being deferred until later for correct geometry.
Fixes #14019.
2024-05-03 16:18:35 +02:00
nanahi
e20ca15b66 win32: support multitouch
Use the multitouch API. To disable system's defualt mouse emulation,
set --native-touch=yes.
2024-05-03 16:14:03 +02:00
nanahi
f0e163bab5 wayland_common: support multitouch
Use the multitouch API. No need to emulate mouse input as it's already
done by the input system.
2024-05-03 16:14:03 +02:00
Dudemanguy
d61d294665 wayland: log if cursor shape support is missing
This is done for the other protocol interfaces already but was
accidentally omitted.
2024-05-02 13:46:20 +02:00
der richter
4a686dac6f mac: properly handle regular expressions without force unwrap 2024-04-28 20:21:18 +02:00
der richter
8f1189341f mac: code cleanup and consistency changes, fix linting issues 2024-04-28 20:21:18 +02:00
der richter
984c890661 mac/helper: make wakeup callback declaration consistent 2024-04-28 20:21:18 +02:00
nanahi
93708a9d38 w32_common: fix show-in-taskbar toggling after explorer is restarted
After explorer is restarted while show-in-taskbar is false, toggling
show-in-taskbar no longer puts mpv back to the taskbar until it's
unfocused and refocused.

My guess of how this works is that the HWND of the taskbar is cached,
and setting the WS_EX_TOOLWINDOW style internally uses this value to
show/hide the taskbar button. But after explorer is restarted it no
longer works until its taskbar state needs to change (such as focusing).
Only then it realizes the HWND is no longer valid and refreshes it.

Fix this by following MS documentation on this: the window needs to be
hidden before changing the style, and be shown after that. This
unfortunately can sometimes introduce a brief window flash, but it
fixes the problem.
2024-04-27 03:02:00 +02:00
Shreesh Adiga
d9c5aef98d vf_gpu: vulkan and egl implementations
Abstract out EGL, and allow choosing between EGL and vulkan at runtime.
vf_gpu_egl.c contains GL specific context and creation/destroy code,
vf_gpu_vulkan.c contains Vulkan specific. This allows vf_gpu being
built in systems where EGL is not available and where Vulkan is
available.
2024-04-27 01:08:22 +02:00
der richter
f7a32b5f29 mac: make display-names unique to allow specific selection
the Screen property localizedName returns a none unique dynamic name
that doesn't allow a specific selection of a Screen on every OS boot.
the name consists of the vendor name and model name (eg DELL U2723QE).
if the same model display is connected to the system several times,
macOS starts to add numbers to the localizedName (eg DELL U2723QE (1)),
that may not be associated to the same Screen on every OS boot or
connecting the display. it also changes the name of the first connected
display by adding that numeration. this makes it impossible specify the
proper screen with the screen-name option every time.

to circumvent this we remove the enumeration from the name and instead
add the serial number to the display-names property. this makes the
actual Screen unique and none dynamic. furthermore the selection of a
screen by name will check for equality for the old localizedName, simple
name without enumeration, serial number and the combined name with
serial number. this makes it possible to select the screen by either of
those names and identifiers, and keeps backwards compatibility with the
old behaviour.

Examples:
localized name (System Settings name): DELL U2723QE, DELL U2723QE (1)
simple name: DELL U2723QE
serial number: 123456789
combined name: DELL U2723QE (123456789)
2024-04-24 20:35:38 +02:00
Dudemanguy
d255f31f98 vo_dmabuf_wayland: use wl_fixed_from_int when setting viewport source
When this was originally implemented, the fixed conversion factor was
accidentally reverse engineered. It was left as is though. Instead, use
the wl_fixed_from_int helper, so it's more obvious what is going on
here.
2024-04-21 13:42:49 -05:00
Dudemanguy
8db1902ae9 vo_dmabuf_wayland: fix scaling for subsurface positioning
It's off if the video aspect ratio doesn't match the monitor aspect
ratio. Fixes c243946338.
2024-04-21 13:42:49 -05:00
Kacper Michajłow
1a495451ab d3d11: disable IDXGIInfoQueue usage if dxgidebug.h is incomplete
Older MinGW-w64 doesn't define IDXGIInfoQueue in dxgidebug.h.
2024-04-19 03:32:29 +02:00
Kacper Michajłow
19a9164e24 d3d11: use IDXGIInfoQueue instead ID3D11InfoQueue
DXGI debug interface encapsulate multiple message queues, which allows
to get validation not only for D3D11 calls, but also DXGI ones.

Also this makes leak detector not report self debug interface as alive
like it was before. And same as with validation, it has ability to
detect more alive objects, not being limited to D3D11.
2024-04-19 03:32:29 +02:00
Dudemanguy
e5d683e187 context_drm_egl: guard gbm_device on uninit
Not all cards support gbm which means the creation of the gbm device
will fail. However during the uninit process, the destruction of the
device was unconditionally done which leads to a segfault. Guard it
instead. Fixes #13929.
2024-04-18 14:57:01 -05:00
Dudemanguy
4d80e7b72c x11: always do a reset_size if geometry/autofit is updated at runtime
Previously, the code required a check against the old saved geometry to
make sure the size and/or position was different before updating. The
doesn't work with the previous changes that allow a geometry value to be
set again with the same value as before. It would probably be nicer to
check against something that always keeps track of the actual window
size in real time, but it seems geometry in x11 doesn't quite work that
way so we'll do it the easier way instead.
2024-04-18 17:40:16 +00:00
nanahi
2533ea764f various: add GPU context description
Now that obj_settings_list is used for GPU contexts, detailed
descriptions can be added so that --gpu-context=help can print
the descriptions of the GPU contexts using standard
obj_settings_list help printing.
2024-04-18 16:28:21 +02:00
nanahi
a6ff33425d video/out/gpu/context: add auto dummy context
This adds a dummy context at the start of the context lists, which
serves three purposes:

- The "auto" option is listed for --gpu-context=help.
- Some special handlings of "auto" string are removed.
- Make sure that lists have at least one element, so MP_ARRAY_SIZE()
  works as intended.
2024-04-18 16:28:21 +02:00
nanahi
96e1f1dfa5 video/out/gpu/context: convert --gpu-context to use obj_settings_list
Since the list of available GPU contexts is a compile time constant,
use obj_settings_list instead of opt_string_validate for GPU contexts.
This has several advantages:

- Aligns with the existing usage of vo, ao, and filter lists.
- Allows custom probing order.
- Allows list option suffixes. (--gpu-context-append, etc.)
- Allows autocomplete in console.lua.
- Uses the standard obj_settings_list help printing, so the custom
  help printing function is no longer needed.

This also deduplicates some context creation code for ra_ctx_create
and ra_ctx_create_by_name.
2024-04-18 16:28:21 +02:00
nanahi
d5ec069829 video/out/gpu/context: don't use hidden flag for contexts
For contexts that have no API, just use a separate list for them.
This keeps validate func for the main contexts simpler.
2024-04-18 16:28:21 +02:00
Kacper Michajłow
2f8038c598 vo_gpu_next: invalidate cache object if requested by libplacebo
See: https://code.videolan.org/videolan/libplacebo/-/merge_requests/659
2024-04-18 02:25:12 +02:00
nanahi
c2ed2e7bc8 terminal: add terminal_set_mouse_input function
This function is used to enable/disable mouse input for win32 and unix.
2024-04-18 01:03:33 +02:00
nanahi
7c6bb9c37b vo_{tct,sixel,kitty}: implement mouse support 2024-04-18 01:03:33 +02:00
nanahi
8c614e0df5 w32_common: implement --show-in-taskbar option
When the window style changes, use WS_EX_TOOLWINDOW style to exclude
the window from the taskbar and Alt+Tab switching.
2024-04-18 00:09:09 +02:00
nanahi
dcd1034529 x11_common: implement --show-in-taskbar option
This adds a new option --show-in-taskbar, which controls whether
mpv appears in taskbars. This is useful for picture-in-picture
setups where the video window should not appear in taskbars.

On X11, this can be controled by setting the
_NET_WM_STATE_SKIP_TASKBAR window state.
2024-04-18 00:09:09 +02:00
nanahi
3a92d7ba3b x11_common: detect wm support for _NET_WM_STATE_SKIP_TASKBAR 2024-04-18 00:09:09 +02:00