Commit Graph

51501 Commits

Author SHA1 Message Date
Mohammad AlSaleh 02a20b4ebe sub: add `--sub-lavc-o` option
We have `--vd-lavc-o` and `--ad-lavc-o`, but no equivalent option for
 subtitles.

Signed-off-by: Mohammad AlSaleh <CE.Mohammad.AlSaleh@gmail.com>
2024-01-21 17:55:11 +00:00
nanahi 1ea9e51f78 win32: stop waiting for messages if the window is destroyed
GetMessageW will indefinitely block after the window is destroyed.
2024-01-21 17:54:57 +00:00
Guido Cella 25bef997ce msg: reset status_lines when setting --really-quiet
This prevents mp_msg_flush_status_line() from printing an unnecessary
newline when changing file after setting --really-quiet at runtime. If
mpv is backgrounded, this newline garbles the output of TUI programs.

With this change the cursor is not re-enabled after setting
--really-quiet at runtime and quitting with mpv in the foreground, so
enable it on uninit.
2024-01-21 17:54:21 +00:00
Dudemanguy a39f9b6181 player: remove --term-remaining-playtime option
This wasn't useful and didn't even really do what it said anyway.
Closes #12167.
2024-01-20 23:24:48 +00:00
Guido Cella 5871ba8f3e command: restore lang after track reload
If a track's language was guessed from its filename, the commands that
reload the track, like sub-reload, remove it. Fix this by calling
guess_lang_from_filename() again.

Note that backing up t->lang and restoring it if nt->lang is NULL would
work incorrectly when lang is in the stream and it is removed before
reloading.
2024-01-20 17:26:45 +00:00
nanahi 02c6165d2b command: minor m_property_strdup_ro style changes 2024-01-20 17:12:07 +00:00
nanahi 2cb1485492 stats.lua: display the current GPU context
This displays the current GPU context when --vo=gpu or --vo=gpu-next
is used, which shows the platform and backend information of the vo
which are previously not available.
2024-01-20 17:12:07 +00:00
nanahi a0ba10b62e command: export current-gpu-context property
This exports `current-gpu-context` property, which is the string
description of the current active GPU context. This allows scripts to
uniquely identify the platform and backend used for --vo=gpu
and --vo=gpu-next.
2024-01-20 17:12:07 +00:00
Dudemanguy 700f72f8e4 player/command: reselect track after UPDATE_SUB_HARD
The lingering cache needs to be cleared so the packets don't stay
forever on the screen past their welcome. Do this by simply refreshing
the stream. Fixes #13148.
2024-01-20 16:39:11 +00:00
llyyr a05c363b7f chmap: mp_image_pool: drop stale mentions of Libav in comments 2024-01-20 16:10:20 +00:00
llyyr 8fe2af09f1 common: stream: don't mention Libav in errors/warnings 2024-01-20 16:10:20 +00:00
llyyr f4a09fada9 TOOLS/autocrop.lua: drop Libav mention 2024-01-20 16:10:20 +00:00
llyyr 5cc0495718 DOCS/*: remove mentions of Libav 2024-01-20 16:10:20 +00:00
Guido Cella 6302a795d2 console.lua: highlight the selected suggestion in the terminal 2024-01-20 16:10:12 +00:00
Guido Cella 07dd577a6b libplacebo: fix out-of-bounds read with --really-quiet
With --really-quiet the message level is -1 which is not in the
msg_lev_to_pl_log enum, so handle it explicitly.
2024-01-20 16:09:54 +00:00
Guido Cella de0849404b scripting: don't observe properties with type nil
mp.observe_property('foo', nil, ...) calls the handler at least 2 times
on each playlist change even when the property doesn't change. This is
dangerous because if you haven't read observe_property's documentation
in a long time this is easy to forget, and you can end up using it for
handlers that are computationally expensive or that cause unintended
side effects.

Therefore, this commit discourages its use more explicitly in the
documentation, and replaces its usages in scripts.

For console.lua, observing focused with type nil leads to calling
mp.osd_message('') when changing file while playing in the terminal with
the console disabled. I don't notice issues from this, but it's safer to
avoid it.

For playlist and track-list this doesn't really matter since they
trigger multiple changes on each new file anyway, but changing it can
avoid encouraging people to imitate the code.

One usage of none in stats.lua is kept because according to b9084dfd47
it is a hack to replicate the deprecated tick event.
2024-01-20 16:09:34 +00:00
nanahi c209d4f73b osc: don't autohide mouse cursor when hovering over windowcontrols title
When the mouse cursor is hovering over the (CSD) windowcontrols title,
the osc keeps displaying, but the cursor autohide isn't disabled like
other visible regions.

Fix this by disabling the cursor autohide in this region.
All other existing behaviors of the mouse cursor in this region
are unchanged, including triggering main window area input
and allowing VO dragging.
2024-01-20 16:09:22 +00:00
sunpenghao b1491bed28 TOOLS/lua/autoload: skip loading when playback is aborted
Quickly going through a directory with too many loadable files causes the
autoload tasks to pile up and exiting the player will take forever. Avoid
this by skipping loading when playback is aborted.
2024-01-20 16:09:12 +00:00
nanahi 3881dc37c5 DOCS: reorder --volume-max documentation to where --volume is 2024-01-20 16:08:33 +00:00
nanahi 27724cab8d DOCS: add documentation for --volume-gain options 2024-01-20 16:08:33 +00:00
nanahi 8c35f8c184 command: add osd display for volume-gain 2024-01-20 16:08:33 +00:00
nanahi f04727145b audio: add --volume-gain options to control volume in decibels
This adds volume-gain, volume-gain-max, volume-gain-min options, which
can be used to control audio volume and target dynamic range in decibels.
The gain is applied on top of the existing volume setting.
2024-01-20 16:08:33 +00:00
Guido Cella 0f2370476b sub: fix sub-seek and sub-step -1 with unknown duration subs
f9cefbfec4 made it so mp_ass_flush_old_events() is continously called on
subtitles with unknown duration, without explaining why, breaking
sub-seek/step -1 with a VO (the issue does not occur when showing
subtitles in the terminal because get_bitmaps() is not called). I don't
experience any issue after removing the call, so delete it to fix these
commands.

After removing that, you can sub-seek -1 once after regular playback,
but not after seeking and thus not multiple times in a row. This is
caused by a714f8e928 which fixed subtitles with unknown duration being
duplicated when seeking with a VO (it does not happen in the terminal)
by clearing old lines on seeks, which broke sub-seek -1 and sub-step -1
in a second way after any seek. The proper fix is to remove the line
ctx->num_seen_packets = 0 for subtitles with unknown duration instead,
which lets decode() return early when a line has already been shown.

Having removed these 2 lines, I also removed sd->preload_ok = false, and
thus the whole conditional, since according to sub/sd.h preload_ok only
needs to be set to false when old subtitles are discarded, and they are
no longer discarded,

The bug can be reproduced with
mpv --sub-file=<(curl 'https://music.xianqiao.wang/neteaseapiv2/lyric?id=1399616170' | jq -r .lrc.lyric) 'https://www.youtube.com/watch?v=dQw4w9WgXcQ'
2024-01-20 16:08:07 +00:00
Guido Cella 5f7ce41371 demux_lavf: detect ico as images 2024-01-19 23:56:21 +00:00
nanahi 146bef059a wayland_common: guard against negative configure sizes
Negative values are nonsense to mpv, and can cause protocol error afterwards,
like xdg_surface::set_window_geometry which doesn't accept negative values.
Treat any negative values as zero (client determines size) for now.
2024-01-19 23:55:52 +00:00
nanahi 92d1e9cd8a command: fix bitrate unit capitalization
This is 1 billion times smaller than it should be in SI units.
2024-01-18 17:06:16 +01:00
llyyr 22e21edbd4 stats.lua: make capitalization consistent across pages 2024-01-17 09:48:06 +01:00
nanahi 9267600792 win32: change to alphanumeric mode on the first keypress
Needed in case the timer solution fails. Note that this will leave the
mode indicator in the language bar showing the original mode until
a key is pressed.
2024-01-15 16:06:06 +00:00
nanahi 758a9658d6 win32: default to alphanumeric input when the IME is first initialized
Some IMEs initialize to composition mode for new windows, which is
undesirable for keyboard control.
Default to alphanumeric input to solve this.
2024-01-15 16:06:06 +00:00
nanahi 7ffd947830 win32: move IME candidate window to video window
By default the IME candidate window appears on the top left corner
of the monitor. Move it to the video window for sane behavior.
2024-01-15 16:06:06 +00:00
nanahi 2b1024fa50 win32: handle WM_UNICHAR
WM_UNICHAR is sent by some 3rd-party IMEs.
2024-01-15 16:06:06 +00:00
nanahi 33e922eabe win32: re-enable IME
The IME is useful for text input. Additionally, Alt+Shift input language
switching doesn't work when IME is disabled even when the languages don't
require IME.

Re-add the VK_PROCESSKEY logic to ensure that IME is handled properly.

Reverts bf6b981367.
2024-01-15 16:06:06 +00:00
Dudemanguy 9bf4b9d5d4 filter_sdh: optimize get_char_bytes
strlen is only relevant if the length is less than [1, 4], so this can
be replaced with strnlen instead which will only traverse characters
upto the maxlen insted of the entire string length. It also makes MPMIN
unneeded. Also fix a comment.
2024-01-15 16:05:17 +00:00
Kacper Michajłow 13ed292ab0 terminal: don't print escape sequence if not tty 2024-01-15 10:39:42 +01:00
NRK ab60ad8619 terminal-unix: don't install handler before pipe 2024-01-15 10:39:42 +01:00
NRK b75b56f910 terminal-unix: move all processing out of sighandler
commit fa9e1f06f tried to move signal unsafe operations out of
signal handlers but mistakenly introduced a race. before,
sigtstop would process the following in order:

0. do_deactivate_getch2();
1. raise(SIGTSTP)

that commit moved 0 out of the signal handler (due to it being
unsafe) but kept 1 in there. this may mess up the ordering of
these operations. this commit moves everything out of the
handler so that things happen in proper order.

since things are now moved out of the handler, SA_RESETHAND is
no longer being applied to SIGTSTP. since that can result in
races if multiple signals are delivered faster than we can
respond to them.
2024-01-15 10:39:42 +01:00
Guido Cella dfecc9f083 console.lua: style log lines in the terminal
When running the console in the terminal, style log lines with the same
escape sequences as msg.c.

mp.input can also specify terminal escape sequences, e.g. a script to
select a playlist entry can invert the color of the selection.

Also add a missing newline to help's error message.
2024-01-14 23:26:07 +01:00
llyyr f33a4d2fd9 terminal-unix: don't set `SA_RESETHAND` for SIGTERM/SIGQUIT
This can cause mpv to abruptly quit without following the proper uninit
process when a second `SIGTERM` or `SIGQUIT` is sent and mpv
didn't quit on the first one already. This is because the default action
for these signals is to terminate the program immediately, similar to
`SIGKILL`, and `SA_RESETHAND` resets the `quit_request_sighandler` to
`SIG_DFL` for the default action.

Also keep the `SA_RESETHAND` flag for SIGINT because the current
behavior is to quit after receiving two Ctrl+C no matter what, this is
probably convenient and worth keeping.

This change is because some tools (e.g. GNU timeout) send SIGTERM twice
after the timeout period.

An easy way to reproduce is with `timeout 1 mpv [...]` where mpv would
quit abruptly anywhere from half the time to once every 50 attempts
depending on your luck.
2024-01-14 23:10:50 +01:00
Kacper Michajłow 5b28c5aa20 Revert "github/workflows: don't install angleproject on msys2"
No longer needed after removal of 32-bit builds.

This reverts commit d56ad8f032.
2024-01-14 22:42:26 +01:00
Kacper Michajłow a56d5c7fa1 github/workflows: disable MSYS 32-bit builds
While mpv can be build for 32-bit platforms, MSYS started dropping some
of the 32-bit packages [1]. We cannot be asked to monitor and fix CI build
each time a dependency package randomly disappears [2].

Disable MSYS 32-bit builds if the support for this platforms is phased
out upstream. Sadly this will reduce our build coverage.

[1] https://www.msys2.org/news/#2023-12-13-starting-to-drop-some-32-bit-packages
[2] fff2fa3711

See also: https://github.com/msys2/MINGW-packages/issues/19747
2024-01-14 22:42:26 +01:00
llyyr bd35dc8ce7 wayland: accept active modifiers even if they aren't physically held
We don't care about the physical state of keys, only if they are
effective or not and whether they should affect key processing.
2024-01-13 17:10:52 +00:00
llyyr 02533e5928 wayland: don't ignore key modifiers if they were consumed
According to the xkbcommon docs, `xkb_state_mod_index_is_consumed` is
true when a modifier *may affect* key translation. A key modifier may
be consumed but not be active. See xkb documentation for this function
for further details. This breaks key modifiers in cases where
L_Shift+R_Shift for example is used to change keyboard layout with
`xkb_options grp:shifts_toggle`. Instead, replace it with a simple
check for a valid modifier.
2024-01-13 17:10:52 +00:00
Guido Cella 43ac656b02 DOCS/mpv: the playback position is not remembered after poweroff
This doesn't actually work on either Windows or Linux with --terminal.
With --no-terminal or --no-input-terminal the SIGTERM handler is never
registered, so it definitely can't work.

Just remove the note about signals because it would be complicated to
explain that they don't terminate abruptly only with --terminal and only
if that signal has a handler, and it wouldn't be of interest to most
users.
2024-01-13 10:45:35 +01:00
Dudemanguy 2ad96079e9 player: add forced choice to subs-with-matching-audio
fe875083b3 confused things a bit and made
--no-subs-with-matching-audio actually mean what it says: no subtitles
if the languages match. However, the option actually meant no non-forced
subtitles not no subtitles at all. This isn't really intuitive so
instead of changing the behavior back to the old way (we already have a
release since then), add a third option "forced" which is equivalent to
the old meaning of --no-subs-with-matching audio. Fixes #13151.
2024-01-13 03:26:06 +00:00
Guido Cella 871f7a152a scripting: add mp.input
This lets scripts get textual input from the user using console.lua.
2024-01-13 02:53:08 +00:00
Dudemanguy 2dd3951a9c filter_sdh: fix incorrect placement of null terminator
The +1 here is not correct. For a 4-byte unicode character, this would
throw a runtime error because the +1 would try to assign the null
terminator past the actual bound of our array. Just remove it since it
should be exactly equal to whatever we have for bytes.
2024-01-12 20:46:00 -06:00
Dudemanguy e15b2b19a3 filter_sdh: sanitize get_char_bytes heuristic to avoid overflow
There's a simple check in filter_sdh that gets the bytes of the first
character in a string in order to do pointer arthimetic to filter the
string. The problem is that it is possible for the amount of bytes to be
greater than the actual length of the string for certain unicode
characters. This can't be worked with so enforce the strlen as the
absolute minimum here to avoid overflow situations.

Fixes #13237.
2024-01-12 20:45:40 -06:00
sfan5 431b420dd6 ao_null: fix reset() implementation
Stopping output implies that it can't be paused anymore.
This is consistent with the documented API in internal.h as well
as the behavior of other AOs.

resolves #13267
2024-01-12 20:36:04 +01:00
llyyr d56ad8f032 github/workflows: don't install angleproject on msys2
This package isn't available for i686 anymore, and not worth the hassle
to only install it for win64 since it isn't particularly useful.

See: fff2fa3711
2024-01-12 17:19:25 +01:00
llyyr bd5d8e41ac demux_lavf: remove `fix_editlists` hack for mp4
Remove this "hack" from 2017 which disabled `advanced_editlist` while
demuxing mov/mp4. See: b7b12c36af as well
as b86a2316df

At present, advanced edit list support seems to be mature enough that it
doesn't need to be disabled by us and disabling it seems to break more
files based on testing with `elist` files in FFmpeg's FATE suite.
2024-01-11 08:44:18 +01:00