Commit Graph

51775 Commits

Author SHA1 Message Date
Dudemanguy d10cebec13 player/video: subtract frame_time from delay when ao_chain starts audio
This seems more robust than relying on the audio status to actually be
playing. For files where there is no audio or the audio start is
delayed, this guards against that but it allows the subtraction to
always occur otherwise on normal files with audio.
2024-03-03 16:24:28 -06:00
Dudemanguy 60abbb424b player/audio: also adjust apts by audio speed in audio_start_ao
Fixes 7051e94e4b
2024-03-03 16:24:17 -06:00
Dudemanguy b08822b8ce test/test_utils: add mp_msg_set_max_level stub
Needed since the previous commit.
2024-03-03 15:15:51 -06:00
nanahi 385031ae2d ci/mingw: update dependency versions 2024-03-03 16:43:02 +01:00
nanahi 7d31db9e45 ci/mingw: add dav1d decoder
ffmpeg has built-in decoders for almost all common formats, except AV1.
dav1d allows the CI build to play AV1 videos without a hwdec-capable GPU.
2024-03-03 16:43:02 +01:00
nanahi a81212836d ci/mingw: enable nvdec
Install the nv-codec-headers to enable nvdec for ffmpeg.
This allows the CI build to enable hwdec on opengl and vulkan contexts.
2024-03-03 16:43:02 +01:00
Dudemanguy 1a649afbad demux_lavf: always find stream info for avif files
avif files will commonly be probed as "mov,mp4,m4a,3gp,3g2,mj2" by
ffmpeg, but demux_lavf currently has some logic to skip
avformat_find_stream_info for these kinds of files. It was introduced in
6f8c953042. Presumably, the optimization
of mentioned in that commit is still valid however for avif we
specifically need to do the avformat_find_stream_info call. Without it,
several codec proprieties like width, height, etc. are unavailable. So
just check the extension type and disable the skipinfo optimization.
2024-03-02 16:32:11 +00:00
Kacper Michajłow 9325ebe817 vo_gpu_next: render subtitles at video colorspace 2024-03-02 15:57:02 +00:00
Kacper Michajłow d6981a4cac sub: add flag if sub_bitmap should be rendered in video color space 2024-03-02 15:57:02 +00:00
psykose c8f1c822dc DOCS/options: fix Vulkan typo 2024-03-02 12:55:49 +01:00
Kacper Michajłow 9189e8982a vo_gpu: add missing PL_COLOR_TRC_ST428 case in lcms 2024-03-01 18:11:43 +00:00
nanahi 34055919f5 wayland_common: toplevel resize fixes
Explicitly send an UP event after the client finishes a resize for
touch event, don't resize if locked_size is set for touch event,
and use the correct type for resize edges.
2024-03-01 18:25:12 +01:00
nanahi fb02626cd9 w32_common: make dragging asynchronous
VOCTRLs are processed in the GUI thread through the mp_dispatch mechanism.
Window dragging requests are asynchronous on x11 and wayland, so the item
is processed quickly without problem. However, currently win32 uses the
SendMessage call for this, which is synchronous. This causes the playback
to stop while the dragging request is being processed because the
dispatch queue is blocked.

Work around this by setting a flag instead if the window dragging is
requested, and immediately starts dragging after processing the dispatch
queue. This doesn't block the dispatch queue while also avoiding any
extra latency added by the Windows message queue.
2024-03-01 18:25:12 +01:00
nanahi 4b8c47d20b w32_common: re-add fullscreen check when start dragging
5736737750 removed the check because it was
not needed to prevent fullscreen window from being dragged. However, this
causes an undesirable behavior: when using a touch screen to drag a window
on Windows 11, DWM shrinks the window content a bit with an acrylic
backdrop to indicate that the window is being dragged. This also happens
when trying to drag the window in fullscreen. Add the check to prevent
this from happening.
2024-03-01 18:25:12 +01:00
nanahi 092f556898 input: centralize VO dragging
Currently, VO dragging logic is hardcoded into each VO, where a left mouse
button down event unconditionally begins dragging if the VO dragging test
passes. This method is extremely unflexible as the VO has no knowledge of
what is happening in the input system: while begin dragging with the second
click of a doubleclick is undesired, it cannot determine whether a click
is a double click or not because it's determined by the input system.

The better way to do it is to handle it somewhere in the downstream
consumers of the events instead, as they have more information to make
this decision. The input system is the perfect place for this as the logic
for checking doubleclick already exists. So just issue a begin-vo-dragging
command if it detects a left mouse button down which isn't also a
doubleclick in this case, and delete all hardcoded VO dragging logic
in win32, x11, and wayland.

Note that this solution hardcodes left mouse button down for now, but
because the VO dragging is now centralized, it's possible to make more
improvements, such as a deadzone mechanism to fix the conflict with
MBTN_LEFT mouse bind.
2024-03-01 18:25:12 +01:00
nanahi c2129c18f8 wayland_common: implement VOCTRL_BEGIN_DRAGGING
This allows begin-vo-dragging command to initialize a vo dragging request
for wayland. The last mouse button press seat and serial is used for the
request if it is not consumed by interactive resizing.
2024-03-01 18:25:12 +01:00
nanahi 14c5da6f50 w32_common: implement VOCTRL_BEGIN_DRAGGING
This allows begin-vo-dragging command to initialize a vo dragging request
for win32. Also set dragging to release all keys like for other platforms.
The hard-coded left mouse button down trigger is scheduled to be removed
in a later commit.
2024-03-01 18:25:12 +01:00
nanahi 6eedf9b1e9 x11_common: implement VOCTRL_BEGIN_DRAGGING
This allows begin-vo-dragging command to initialize a vo dragging request
for x11. The last mouse button press event is used for _NET_WM_MOVERESIZE.
The hard-coded left mouse button down trigger is scheduled to be removed
in a later commit.
2024-03-01 18:25:12 +01:00
nanahi 9d03b83a6c command: add begin-vo-dragging command
This command initializes a vo dragging request for VOs that implement
the new VOCTRL_BEGIN_DRAGGING voctrl. This allows scripts to begin vo
dragging for any button press event.
2024-03-01 18:25:12 +01:00
Dudemanguy 4560d93bf0 Revert "player: add ao-volume option, to set the system volume at startup"
Ended up being a bad idea. As a property, this inherently has more
functionality and the tradeoff of being able to do --ao-volume wasn't
worth it.

This reverts commit 58ed620c06.
2024-03-01 09:20:15 -06:00
Dudemanguy 8ba6d8f7a9 sd_ass: fix use-after-free in ft->event_format
0b35b4c917 originally introduced sd_filter
to make a more general subtitle filter infrastructure. But when doing
so, it directly sets ft->event_format to ass_track->event_format in the
struct. The lifetime of ass_track and the sd_filter are not equivalent
which makes it easy to trigger undefined behavior. Notably, commit
cda8f1613f introduced assobjects_destroy
which can destroy ass_track anytime during runtime which means that the
string in ft->event_format is actually freed and should never be used.
Remedy this by simply doing a proper strdup when the filter inits with
ft as the parent so we avoid this scenario altogether. Fixex #13525.
2024-02-29 15:57:58 -06:00
sfan5 dafced8a8a wayland_common: fix type of dnd_action
The default value of -1 and comparisons >= 0 only work properly
with an int type.
2024-02-29 17:24:05 +01:00
sfan5 878b76f75e wayland_common: fix initialization order issue with protocols
This broke DND under (apparently) GNOME and KWin, but not sway.

fixes: 2274311b25
2024-02-29 17:24:05 +01:00
sfan5 78cedac844 wayland_common: fix DND read error handling 2024-02-29 17:24:05 +01:00
sfan5 dec29e82ac wayland_common: read DND data in larger chunks 2024-02-29 17:24:05 +01:00
sfan5 98f7f9e25e wayland_common: log if DND fails
This can happen if the compositor or applications don't behave correctly,
so let the user know to aid debugging.
2024-02-29 17:24:05 +01:00
sfan5 f36ab2c609 wayland_common: free DND resources on shutdown and error
This leaked only in edge cases, if at all.
2024-02-29 17:24:05 +01:00
der richter 15c48f3dc1 cocoa-cb: render on main queue instead of dedicated queue
initially we drew on a dedicated render queue to circumvent certain
bottlenecks on the main queue, like concurrent events that could lead
to late drawing.

though due to the way cocoa works we need to draw an the main queue
otherwise we get undefined behaviour that could lead to crashes.

Fixes #10276
2024-02-29 16:40:52 +01:00
der richter 7758f6f50e mac/vulkan: set NSView as layer delegate like recommended by MoltenVK 2024-02-29 16:38:10 +01:00
der richter 9b301a0537 osxbundle: fix bundling when homebrew is not installed
Fixes #13603
2024-02-29 16:37:21 +01:00
der richter be6c22f93b mac/vulkan: remove old deprecated VK_MVK_macos_surface extension remains 2024-02-29 14:06:14 +01:00
Kacper Michajłow 0897604298 various: avoid function pointer casts
The opt validator functions are casted to generic validator, which has
erased type for value. Calling function by pointer of different
definition is an UB.

Avoid that by generating wrapper function that does proper argument type
conversion and calls validator function. Type erased functions have
mangled type in the name.

Fixes UBSAN failures on Clang 17, which enabled fsanitize=function by
default.
2024-02-28 16:04:02 +00:00
sfan5 d955dfab29 misc/jni: reduce duplication in mapping struct
'name' was in fact unused when reading fields or methods, so it can be merged with 'method'.
Also changed the type of 'mandatory' to bool.
2024-02-28 16:11:54 +01:00
sfan5 5b1eaf3ff1 misc/jni: introduce macros for deleting references 2024-02-28 16:11:54 +01:00
sfan5 75ae44472b misc/jni: general code cleanup and refactor
Make it align with mpv's coding conventions in general and avoid unecessary Lavu use.
2024-02-28 16:11:54 +01:00
sfan5 1f3758adea ao_audiotrack: refactor JNI class retrieval
- split mapping from field struct
- mark field struct static
- define list of classes to reduce more repetitive code
2024-02-28 16:11:54 +01:00
sfan5 87d30899ff ao_audiotrack: remove two dead variables 2024-02-28 16:11:54 +01:00
sfan5 3c1c848c2b ao_audiotrack: fix missing check for passthrough support 2024-02-28 16:11:54 +01:00
der richter 86fa9b18a3 osdep/mac: make mac naming of files, folders and function consistent
rename all macOS namings (osx, macosx, macOS, macos, apple) to mac, to
make naming consistent.
2024-02-28 15:52:47 +01:00
Dudemanguy 661f45377a wayland: drop some unneeded curly braces (no-op)
Not sure why all of these single line if's were being braced. Probably
some cargo cult from years ago but might as well fix it now since it's
bothering me.
2024-02-27 22:18:12 +00:00
Dudemanguy f0a6578259 wayland: drop buffer scale for cursor as well
Could have been done in e32554cd57, but I
skipped it there. However, using viewporter is actually a win here.
There's been a longstanding issue in upstream wayland* exactly related
to this. I even forgot about cd7a7a1de8
which was made for this exactly problem and explains the random
spawn_cursor calls. Anyways, just not using buffer scale and instead
scaling the cursor surface via viewporter works just fine and completely
sidesteps this problem. This means we can drop the random looking
spawn_cursor calls and some additional checks.

*: https://gitlab.freedesktop.org/wayland/wayland/-/issues/194
2024-02-27 22:18:12 +00:00
Dudemanguy 34c0a67ace wayland: rename configured to geometry_configured (no-op)
Makes it clearer.
2024-02-27 22:18:12 +00:00
Dudemanguy 7b03a2ff17 wayland: fix check for set_surface_scaling
We don't want to use this if we have fractional scaling or version 6 of
the wl_surface interface which has a preferred buffer scale event which
is superior to this. We were checking in the important place (surface
entrance events) but not technically in the output. So just move the
conditional to set_surface_scaling itself. Also through the VO_EVENT_DPI
in there for convenience.
2024-02-27 22:18:12 +00:00
Christoph Heinrich 505a08a37f sd_ass: don't wrongly recognize \pos as \p
An ass event like `{\p1\pos{1,1}}m 0 0 l -3 -7 l 11 -7 l 11 -2` ends
the drawing mode started with `\p1` due to `\pos` gets confused with
`\p`, and thus that line is wrongly considered to be visible text.
2024-02-27 19:50:03 +00:00
der richter c7ff037fdd build: fix build when disabling cocoa-cb
the swift obj-c bridging header is only included when cocoa-cb is
enabled. cocoa-cb is not the only swift feature anymore and disabling
cocoa-cb leads to a runtime error that specific swift classes could not
be found.

include the swift obj-c bridging header in the case swift features are
enabled.
2024-02-27 14:04:30 +01:00
der richter c15307244f mac: remove unnecessary metal layer colour space update
this logic was copied from the cocoa-cb opengl backend, since it was
assumed both layers work similar. apparently they don't and a nil value
on the metal layer means use the display colour profile, while on the
opengl layer it means undefined behaviour.

this also fixes a problem with the target-colorspace-hint option, since
moltenvk needs to set this colour space itself for a proper hint. both
mechanism would compete to set the colour space.
2024-02-27 14:03:15 +01:00
der richter 7a1b387aa9 mac: set layer content scale on init
usually the content scale updates automatically, though on init it is
possible the wrong scale is used for the initial rendering leading to a
wrongly sized surface.

properly set the initial content scale of the layer.
2024-02-27 14:02:08 +01:00
der richter a7c4a113b8 cocoa-cb: remove pre-allocation and initialise only when used
cocoa-cb was always pre-allocated in the Application itself because
libmpv needs to be set up before usage, an opengl context has to be set
and because it was decided mac specific code should be kept out of
libmpv.

this means that a completely working libmpv and opengl renderer was set
up even if it wasn't used. leading to unnecessary log message, resources
being used or reserved on the system that might not be used, triggering
of dedicated GPU unnecessarily and many other things.

even if not optimal, this wasn't the biggest problem since we only had
that one working vo on macOS. though now that we have a vulkan
gpu(-next) backend on macOS that was made the default, we always have
that dangling cocoa-cb instance, which is completely unnecessary.

move the cocoa-cb initialisation into libmpv preinit function and only
init cocoa-cb when we are a standalone App and cocoa-cb support is build
into.
2024-02-27 14:01:38 +01:00
nanahi 3dcc661de7 console.lua: fix blurry cursor when --osd-blur is set
This is drawn with the same method as the stats.lua graphs so it's also
blurry. Fix this by using the "Default" style for cursor drawing.
2024-02-27 08:36:56 +01:00
nanahi f4af7b683e stats.lua: fix blurry graphs when --osd-blur is set
When --osd-blur is set to a nonzero value, the graphs also become
blurry. This is because they are rendered by the osd-overlay command
with the "OSD" style which has OSD blur applied, and are treated no
differently from texts. Fix this by using the "Default" style for
these graphs which uses the default OSD options.
2024-02-27 08:36:56 +01:00