Commit Graph

52898 Commits

Author SHA1 Message Date
Kacper Michajłow c0f5d2391b ytdl_hook.lua: fix hook triggering while it shouldn't
Fixes: acbd537dac
Fixes: #14522
2024-07-12 11:11:54 +02:00
Kacper Michajłow f470b63a04 input.conf: add zoom, pan, scale and rotate keybinds for numpad 2024-07-11 21:57:11 +02:00
Kacper Michajłow c505f77dda player/core: add core thread handle to MPContext
This change removes convoluted core thread extraction through dispatch
added in 500ce69a06.

Currently we fully control this thread, create it and join, there is no
reason not to keep the handle of it in the player context.

As a bonus to code simplification this also fixes thread handle leak on
Windows.

Fixes: #14472
2024-07-11 21:55:21 +02:00
Kacper Michajłow 09b25771e8 fuzzer_set_property: set duration to 0.1s
It looks like it is faster than 0.01s.
2024-07-11 21:55:21 +02:00
Kacper Michajłow b3320ac64a test/libmpv_lifetime: add test to test libmpv ability to reinit itself
This test:
- Checks if libmpv can be loaded dynamically.
- Checks for leaks after mpv context destroy.
- Checks if libmpv can be reloads after dlclose()
2024-07-11 21:55:21 +02: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
Kacper Michajłow 9158653982 demux_mkv: ignore duplicated BlockAdditions to avoid memory leak
This can happen only on invalid files.

Found by OSS-Fuzz.
2024-07-11 03:48:25 +02:00
Kacper Michajłow b13642e115 player/loadfile: prevent fuzzers from loading absolute directories
It's waste of time to load external files. And it is not deterministic.

Note we still allow to load single files by name, but it is not a big
deal.
2024-07-11 03:48:25 +02:00
Kacper Michajłow aea5b3dbea player/loadfile: cancel playback cleanly if thread fails to start
Currently it would crash, due to already canceled and freed resources.
2024-07-11 03:48:25 +02:00
Kacper Michajłow 66fdec8a67 demux_edl: don't try to extract dirname from self-expanding protocols
Fixes infinite recursion. Trying to extract dirname from string of
memory://<data> is not really a good idea.

Found by OSS-Fuzz.
2024-07-11 03:48:25 +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
holdingsllc 18b557c1c7 DOCS/input: fix "does does" typo 2024-07-10 19:16:38 +00:00
llyyr 1fd9389911 ao: don't add buffer length to timeout twice
ao_get_delay already adds this buffer length
2024-07-10 19:32:36 +02:00
llyyr 2559f8874f ao: use the right type for pending samples 2024-07-10 19:32:36 +02:00
Kacper Michajłow 571f9b0f23 demux/ebml: fix ebml size check
There was one zero too many. Change the limit to 128 MiB with more
readable notation.
2024-07-09 20:58:39 +02:00
llyyr daa6068d02 stream_bluray: check fread return value 2024-07-08 23:45:37 +02:00
llyyr f89d0d48bc test/libmpv_encode: check fread return value
Fixes warning with clang
2024-07-08 23:45:37 +02: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
llyyr 539e95730a ao_pipewire: bump minimum libpipewire version to 0.3.57
available on debian stable
2024-07-08 13:33:32 +00:00
Kacper Michajłow acbd537dac ytdl_hook.lua: allow changing try_ytdl_first during runtime
Check value in hook instead of hooking conditionally.
2024-07-07 02:32:48 +02: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
verygoodlee bcc72f97ef stats.lua: active key bindings: identify prefix nonrepeatable
The nonrepeatable prefix was added at commit bc5863a
2024-07-05 16:42:31 +03:00
Guido Cella e07470adc2 console.lua: restore the order of items after clearing the input line
When you type something in select mode and then delete it, table.sort
changes how selectable items are sorted. Restore the order specified by
the mp.input caller in this case.
2024-07-04 22:24:10 +00:00
Guido Cella 97af5c98f4 console.lua: minor tweaks
- Remove the opts comments because they are already in console.rst and
  will become outdated if not updated in both places
- Reuse last_pos in truncate_utf8() instead of recalculating the
  previous character's position
- Clear the OSD earlier when the console is not active
2024-07-04 22:24:10 +00:00
Guido Cella 49afdb9365 console.lua: remove the scale script-opt
This is redundant because you can set font_size and border_size to have
the same effect.
2024-07-04 22:24:10 +00:00
nanahi b09e48e388 player/loadfile: enable streams in order of types when loading file
The previous commit to avoid refresh seeking video streams has an edge
case when enabling tracks when loading files. Since the streams are
initially unselected and then multiple streams are enabled, the detection
only works reliably when video tracks are enabled first.

This makes sure that loading file enables tracks in a predictable order.
2024-07-04 22:23:27 +00:00
nanahi 33e414fa5d demux: avoid seeking video streams for refresh seek
940854c86f added this logic, but when the
demuxer contains a selected video stream, it causes a seek for the video
stream. This is unnecessary since the problems that commit fixed are only
relevant for external audio streams. For a demuxer with a video stream
selected, the synchronization is done by the demuxer implementation.
Add a check to prevent this.
2024-07-04 22:23:27 +00:00
nanahi c461ea6cd1 demux: don't log if track isn't refreshed
Also use demux_internal type for the refresh_track in style of other
internal functions.
2024-07-04 22:23:27 +00: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
bashonly e78e2c73cf ytdl_hook: strip quotes from cookie values 2024-07-04 19:10:37 +00:00
nanahi 7c70df0934 input/cmd: move m_option_type_cycle_dir to m_option.c
A relic when commands lived in input.c. Move them to where other option
types live. Also remove the redundant copy_opt.
2024-07-01 10:02:13 +02:00
Kacper Michajłow 4969d6e03e player/lua: restore original lua allocator before close
We wrap the default Lua allocator to allow used memory tracking. This
works well, except that we never destroy the default allocator or notify
it that we are closing. Since we override it for the current Lua state,
it is reasonable that the Lua engine does not expect it to be used. We
get and pass through a free call, but in the case of LuaJIT, the
internal allocator has additional state and is freed differently. So, in
fact, it is a LuaJIT leak because once we replace the allocator with our
custom one, they should clean its internal state. I guess the assumption
is to override allocator only before any allocation happen. To work
around this issue, restore the default allocator, the one that we use,
before closing the state. This way, everything is cleared as expected.

Note that the current solution of wrapping the default allocator works
only because none of the supported Lua engines actually invalidate the
allocator on the lua_setallocf() call. However, they could, so keep in
mind that we are currently depending on an implementation detail.

Thanks to @Dudemanguy for help with finding the changes that introduced
the leak.

Fixes: a67bda2840
Fixes: #14451
2024-06-30 21:15:37 +02: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
Kacper Michajłow a3f72ea87c stats.lua: fix codec-profile position for audio 2024-06-27 20:24:13 +02:00
nanahi ea03451d1e misc/natural_sort: avoid implementation-defined behavior in comparison
Before a7158ceec0, string comparision was
done with strcmp, which does unsigned comparison. The natural sort
implementation instead compares on char values.
This causes implementation-defined behavior in comparison, depending on
the signedness of char type.

Fix this by using unsigned comparison instead.
2024-06-27 19:45:21 +03:00
Kacper Michajłow 4574644b7a fuzzers: wait for file start event before idle
Sometimes we exited too soon, not waiting for full transition to idle
state.
2024-06-27 02:57:22 +02:00
Kacper Michajłow 995283bd7a filters/f_lavfi: fix null dereference on empty graph 2024-06-27 02:57:22 +02:00
Kacper Michajłow 2b1e9a6537 demux_playlist: don't add base path to self-expanding protocols
Adding base path make sense only if it is a real directory or url
location. In case of protocols like memory adding base path to playlist
entry in facts adds the whole playlist to that entry.

For example `mpv $'memory://#EXTM3U\na/b'` produces infinite loop,
expanding playlist, adding more to it.

open_file adds the dirname to support relative playlist enties, however,
the dirname is invalid when the name doesn't represent a path, such as
with memory://..., so avoid taking the dirname with such protocols.

Found by OSS-Fuzz.
2024-06-27 02:57:22 +02:00
Kacper Michajłow 529450a965 test/paths: add tests for mp_basename and mp_dirname
Note that those functions have different behaviour than POSIX ones.
2024-06-27 02:56:59 +02:00
Kacper Michajłow 4a0c0ce92d test/paths: use helper functions for result testing 2024-06-27 02:56:59 +02:00
Kacper Michajłow 22fc2e6af3 bstr: change memcpy to memmove to allow aliased copies
mp_property_expand_escaped_string() needs this.

Found by OSS-Fuzz.
2024-06-26 01:28:55 +02:00
Kacper Michajłow 5995f13b5f fuzzer_set_property: fix setting audio-files list
`:` were not escaped correctly. Also while at it clear other external
file lists, as we don't want to load any. Subtitle fuzzer will be added
in the future.

It is surprisingly hard to clear the list with C API. That needs whole
mpv_node_list with 0 elements, to make it clear it.
2024-06-26 01:28:55 +02:00
der richter 88db2d0b61 mac/menu: add option to disable default shortcuts
Fixes #14305
2024-06-25 20:14:38 +02:00
Kacper Michajłow 95ac32220e m_option: parse the timestamp as unsigned value
The sign is handled manually. This allows us to skip the check for
negative integers.
2024-06-25 05:29:46 +02:00
Kacper Michajłow 7fb7e1dd73 various: add more format specifiers checks 2024-06-25 05:29:46 +02:00
Dudemanguy 0db6abadd4 playlist: let playlist-next go to first item if player is idle
Similar to the previous commit but the other way around. If you start
mpv as idle, load up a playlist without immediately hitting play and
then try to go to the next item, nothing happens. Naturally, you would
expect this to go to the first item. Fix this detecting if the playlist
has not started yet, the direction, and going to the first item in the
list.
2024-06-25 02:19:08 +00:00
Dudemanguy 0f76848e5f playlist: let playlist-prev go to last item in playlist
Previously, playlist-prev didn't work if you played a playlist to
completion using --idle and tried to go back. Naturally, one would
expect this to bring up the last item in the playlist, but nothing
happens. This is just because playlist_get_next is stupid and doesn't
take this into account since pl->current is NULL and thus returns NULL.
Fix this by considering the direction, checking if the playlist was
played to completion and grabbing the last entry in the index.
2024-06-25 02:19:08 +00:00