Commit Graph
53912 Commits
Author SHA1 Message Date
Kacper Michajłow f751f218bc commands.lua: add cache for often queried constant properties
commands, properties, options, options info, never changes during
runtime, so we can cache them to make the value instantly available.
2025-03-09 11:45:30 +01:00
Kacper MichajłowandGuido Cella d37521b5ef console.lua: cache observed properties to avoid unnecessary fetching
Those properties are already observed and trigger update, remember the
value to avoid re-fetching them.

This fixes delay caused by properties that synchronize GUI thread like
`focused` which takes 30+ ms in certain cases.

Co-authored-by: Guido Cella <guido@guidocella.xyz>
2025-03-09 11:45:30 +01:00
llyyr 4b1315a67f DOCS/man/input: remove stray newline
this breaks the html conversion
2025-03-09 10:56:15 +01:00
Kacper Michajłow d9cf7a3d39 demux_mkv: add A_ATRAC/AT1 support 2025-03-08 21:28:58 +01:00
Kacper Michajłow de52c6276e demux_mkv: set number of samples correctly for The True Audio
14-17	Data length in samples (binary, Little Endian)

This has been validated with sample generated with:
ffmpeg -i $(ffmpeg_fate)/lossless-audio/luckynight-partial.tak -c:a tta lucky.mka

The length is correctly calculated to be 418950 for that sample.

Basically this is a port of https://github.com/FFmpeg/FFmpeg/commit/af248fa1174200acb537a6ab1198bb2fed38e884

Fixes: d53d75e080
2025-03-08 21:28:58 +01:00
Kacper Michajłow a0d164ccaa demux_mkv: add sanity checks for RealAudio packet sizes
This fixes feeding unitialized data in some cases on corrupted/fuzzed
files.
2025-03-08 21:28:58 +01:00
Guido Cella 8385c2b5e8 console.lua: convert cursor_position to number
script-message-to commands type was passing cursor_position as a string,
which caused a crash if you e.g. moved the cursor afterwards. Convert it
to number in console so commands.lua and similar clients don't have to
manually convert it.
2025-03-08 19:09:23 +00:00
Guido Cella 061b83d479 commands.lua: complete filesystem paths for run
Complete file paths after e.g. run mv ${path}. This is similar to how
shells complete file paths for all commands without known completions.
2025-03-08 19:09:23 +00:00
Guido Cella e28c6ceea3 console.lua: default to --osd-font without completions
Currently --osd-font is the default for select, and a monospace font is
the default for free-form text mode. We can also default to the
proportional --osd-font for mp.input.get clients that don't specify
completions and thus don't need alignment, which is most clients.

In builtin scripts, this is the case for filtering stats key bindings.
2025-03-08 19:09:23 +00:00
Guido Cella d738e787a0 console.lua: instantly show completions with the type script message
With script-message-to commands type, instantly show completions if
available. Useful e.g. with loadfile or apply-profile.

This also shows completions if you just close the console with a filled
line and reopen it.
2025-03-08 19:09:23 +00:00
Guido Cella 415078ba2d console.lua: fix the line end position to filter completions
Completions were not being shown if a character in front of the cursor
was not in the completions, e.g. with loadfile '...'
2025-03-08 19:09:23 +00:00
Guido Cella 10bb083ab4 console.lua: don't retrieve --input-ime at startup
This is already retrieved when opening the console.
2025-03-08 19:09:23 +00:00
Guido Cella a839738d1c console.lua: reduce indentation in 2 functions
Nest the shorter blocks instead of the longer ones.
2025-03-08 19:09:23 +00:00
Guido Cella b23bd34921 console.lua: inline log_add()
As it's now used in a single place.
2025-03-08 19:09:23 +00:00
Guido Cella 686eb160e4 console.lua: clear the default item on input.get()
Clear the default item of the last input.select() call to prevent
command history search from highlighting that same default item.
2025-03-08 19:09:23 +00:00
Guido Cella a6024b562a console.lua: declare various variables only in free-form text mode
These are no longer used anywhere in select mode, except for 1 instance
of log_buffers[id].
2025-03-08 19:09:23 +00:00
Guido Cella 6f2ce8aac1 console.lua: don't duplicate the check to add to history 2025-03-08 19:09:23 +00:00
Guido Cella 0b3cc3a167 commands.lua: split this script out of console.lua
It was suggested by CogentRedTester in
https://github.com/mpv-player/mpv/pull/10282#issuecomment-1858727729 and
https://github.com/mpv-player/mpv/pull/10282#issuecomment-1858809580 and
by avih that making running commands an mp.input client is a better
architecture.

A practical advantage is that completions are calculated in a different
thread, which prevents hanging when completing slow/network filesystems.

script-binding console/enable becomes script-binding commands/open,
though the console one is kept as an alias. I took the opportunity to
rename this because open makes more sense for a graphical modal, and it
is the word used in mp.input and user-data.

script-message-to console type becomes script-message-to commands type,
though the console one is kept as an alias. It is also changed to
automatically close on submit without having to append '; keypress ESC'
as you don't need to keep the console open after running prefilled
commands.

Also convert to double quotes like other scripts and rename some
inconsistent functions.
2025-03-08 19:09:23 +00:00
Guido Cella ce6a52d40a console.lua: add history_path field to mp.input.get
This allows saving the history to all mp.input.get clients.

Needed to split running commands out of console.lua.
2025-03-08 19:09:23 +00:00
Guido Cella 05438fc081 console.lua: add autoselect_completion field to mp.input.get
This selects the first completion when pressing Enter when one wasn't
already manually selected.

Needed to split running commands out of console.lua.
2025-03-08 19:09:23 +00:00
Guido Cella 3c175f0114 console.lua: let the complete callback return a character to append
Let the complete callback return the character to append to the selected
completion.

I didn't want to document this because it's specifically meant for
properties and unlikely to be needed by other scripts, but silently
interpreting the 3rd return value can screw you over if you do something
like

return candidates, code:find('[%w_]*$')

I was doing this in my lua-repl script, and find() returns the end
position as the 2rd argument, this becomes the 3rd return value and gets
appended to completions. So you have to do

return candidates, code:find('[%w_]*$'), nil

Needed to split running commands out of console.lua.
2025-03-08 19:09:23 +00:00
Guido Cella c7e62ee28c DOCS/man/lua: update complete docs referencing autocompletion 2025-03-08 19:09:23 +00:00
Jaime Marquínez Ferrándiz 561156217e fish-completion: create the fish completion script
It is an adaptation of the bash completion.
2025-03-08 00:25:45 +01:00
Kacper Michajłow ecc31ecab3 player/command: add attached-picture flags to track add command 2025-03-08 00:21:06 +01:00
Kacper Michajłow 7b9290f620 player/command: add visual-impaired flags to track add command 2025-03-08 00:21:06 +01:00
Kacper Michajłow 3147eca943 player/command: convert flags to OPT_FLAGS for track add commands 2025-03-08 00:21:06 +01:00
Kacper Michajłow 7df3f442ea misc/language: parse hi/sdh/cc tags from external subtitle tracks
This also adds `hearing-impaired` argument to `sub-add` command.

Fixes: #14805
2025-03-08 00:21:06 +01:00
Kacper Michajłow 415b70dc7b misc/mp_assert: important fix forgotten before merge 2025-03-07 22:11:05 +01:00
Kacper Michajłow 91f80b5948 demux_timeline: don't close segments during demuxing
add_tl() when creating virtual_stream list is referencing sh->codec
which is owned by the demuxer. Don't close it to avoid dangling
pointers. The comment is right, but this happens regardless of
delay_open as we can clearly see in the add_tl() function.
2025-03-07 20:32:37 +01:00
Dudemanguy 533a684381 player: only coalesce callbacks from parsed config files
This relaxes what bbac628a1b introduced.
Although it is rare, there may be scripts out there that depend on the
old timing. We'd still like to process config files in a sane manner and
not cause OOMs so keep the general coalescing mechanism in place but use
it selectively. There is one special case with the --input-commands
option. We want this coalesced as well so some special handling needs to
be added for that.
2025-03-07 14:35:52 +00:00
Kacper Michajłow f152674246 stream_edl: allow opening edl only from local resources
edl is complex and prone to errors. Also there is no good reason for
external network playlist to require edl use.
2025-03-07 14:19:15 +01:00
Kacper Michajłow babea3da1f Revert "stream/stream: mark mf:// and edl:// as unsafe protocols"
At least part of it, because there was rebase error in original commit
with unrelated changes.

This reverts commit 9bc3aee6fb.
2025-03-07 14:19:15 +01:00
Kacper Michajłow 45c6077756 stream_mpv: restrict only to network links 2025-03-07 14:19:15 +01:00
sfan5 839aa31b7e player/client: adjust log message for client exit
The old message is too generic and worse could be mistaken
for exit of the entire player.
2025-03-07 09:44:19 +01:00
sfan5 53a6a6821c player/scripting: add logging around script un- and reloading 2025-03-07 09:44:19 +01:00
Dudemanguy 2a49bf11ec vo: replace driver->frame_owner with VO_CAP_FRAMEOWNER 2025-03-07 03:25:51 +00:00
Dudemanguy 8798cec7fa vo: replace driver->untimed with VO_CAP_UNTIMED
There's a weird mix and match of ways to set special things about a VO
so let's consolidate it all to use VO_CAP bits. More importantly this
fixes do_redraw not being properly ignored/skipped in the untimed VO
case. This was intended in 8657b8e1f3 but
later the code got reorganized/moved around to make it no longer a no-op
but we just got lucky and there were not any known problems with the
broken logic until 5338f4ba70.
2025-03-07 03:25:51 +00:00
Kacper Michajłow 2799d8b130 mac/apphub: remove mpv:// protocol handling
It has been moved to the mpv core with additional security
considerations, including filtering unsafe protocols from being opened
via the URL handler.

While we are not aware of any active exploitation, naive protocol
handling could allow the use of niche protocols in FFmpeg, which, in
turn, might load native code. How such native code would be dropped on
the local machine is another question.

This remains theoretical, but it's better to be safe than sorry.

Fixes: 494d408583
2025-03-07 00:15:23 +01:00
Kacper Michajłow 93ea3df0a9 player: add mpv:// protocol
This is useful to run mpv from URL handler. Can be used to start mpv
from you web browser or anything that would trigger url handler for
given protocol. Only safe protocols are allowed.

Current solutions to run mpv in such context are to spawn IPC proxy and
run mpv when requested, but this is in most cases not necessary.

Currently the protocol is added in mpv.desktop. Windows related
registration will follow in future changes.
2025-03-07 00:15:23 +01:00
Kacper Michajłow 9bc3aee6fb stream/stream: mark mf:// and edl:// as unsafe protocols 2025-03-07 00:15:23 +01:00
Kacper Michajłow 27f39811fa etc/mpv.desktop: update safe protocol list 2025-03-07 00:15:23 +01:00
Kacper Michajłow d2e3fd9383 auto_profiles.lua: make profiles apply with higher priority
This increases the priority from 50 (which is neutral) to ensure that
profiles are applied before other scripts.

In general, applying profiles before other scripts makes sense. This was
already the case for external scripts with default priority because they
would load after auto_profiles.

This commit primarily fixes ytdl_hook.lua to respond to profile changes.
In most cases, profile conditions are triggered by external conditions,
not the output from the ytdl hook, so this is fine.

I acknowledge that this will change the order if a script previously had
a priority lower than 50. However, injecting itself before profiles are
evaluated is a very obscure use case, if there is even a valid one.
2025-03-07 00:08:10 +01:00
Kacper Michajłow dddfdf2504 player/sub: avoid indexing arrays with -1 2025-03-06 21:58:38 +01:00
Kacper Michajłow 442e21a69c demux_mkv: add missing invalid value check 2025-03-06 21:58:38 +01:00
Kacper Michajłow d035a63913 stream_dvdnav: cast to int64_t before multiplication
Just to silence static analysis warning. It is assigned to int64_t
anyway.
2025-03-06 21:58:38 +01:00
Kacper Michajłow 41d03dca2a {x11,wayland}_common: convert dead code to static sanity check 2025-03-06 21:58:38 +01:00
Kacper Michajłow dd107a1a39 stream_cdda: cast to int64_t before multiplication
Just to silence static analysis warning. It is assigned to int64_t
anyway.
2025-03-06 21:58:38 +01:00
Kacper Michajłow f7c2af2acd player/command: remove redundant check 2025-03-06 21:58:38 +01:00
Kacper Michajłow 25fa0bd08a player/loadfile: fix history_file leak 2025-03-06 21:58:38 +01:00
Kacper Michajłow 6496de424c player/sub: check order before using it as an index 2025-03-06 21:58:38 +01:00