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

51488 Commits

Author SHA1 Message Date
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
llyyr
10321b869f f_lavfi: provide color_space and color_range params for lavfi
Only when the lavfi version is sufficiently new enough to actually have
these fields. See:
2d555dc82d

Fixes #13234
2024-01-11 07:05:35 +01:00
nanahi
4b69164147 x11_common: prefer Xft.dpi for HiDPI scaling
Xft.dpi is much more widely used nowadays by GUI programs compared to
the X11 screen DPI.
This is the best we can get for a vendor-neutral scaling preference
value under X11 in terms of adoption.
If Xft.dpi isn't available, the X11 screen DPI is used as a fallback.
2024-01-10 00:33:05 +01:00
nanahi
a504e696c8 x11_common: allow DPI scale in unit of 0.5
~144 DPI displays are pretty common and neither 1x nor 2x scales are
the right size for it. Allow DPI scale in unit of 0.5 to fix this.

Additionally, add a note about the current behavior of the API used
to get the scale factor.
2024-01-10 00:33:05 +01:00
Kacper Michajłow
485221ba22 msg: return zero length if bstr_split_utf8 fails
In theory bstr_split_utf8 should skip invalid sequence and move further,
but it doesn't do that currently, so just the string if unsuported code if
found.

Fixes infinite loop on code.len == 0 condition.

Fixes: 5864b72d1a
2024-01-10 00:31:57 +01:00
nanahi
41259db952 vo_gpu_next: respect d3d11 swapchain output format preference
Currently, libplacebo always tries to reconfigure the d3d11 swapchain
to a 10-bit output format because disable_10bit_sdr isn't set to true,
even when an 8-bit format is explicitly requested via
--d3d11-output-format.

Fix this by passing the requested output format preference to libplacebo.
Document that this option may be ignored.
2024-01-06 23:46:12 +01:00
nanahi
f0bcbdcf76 README: specify the meaning of "not too ancient Linux"
Commits like 3b19866882 show that in
practice, only the lastest releases of popular distributions are
supported.
2024-01-06 21:33:30 +01:00
nanahi
5aae6bbf4e README: recommend --profile=fast for crappy GPUs
0.37.0 uses more computationally expensive shaders by default,
which can cause high GPU usage and frame drops even for modern
integrated GPUs, especially with 4K and high fps contents.
Recommend --profile=fast for them.
2024-01-06 21:33:30 +01:00
Dudemanguy
d8c2e33a5d DOCS/options: note that --geometry doesn't fully work on wayland
Positioning windows won't work on wayland so note it here to hopefully
avoid confusing users.
2024-01-04 14:47:06 -06:00
Guido Cella
448cb4d13d console.lua: expand ~/ in file completion
Makes Tab expand loadfile ~/ to loadfile /home/$USER/.

I used expand-path instead of os.getenv('HOME') to make it work on
Windows.
2024-01-04 13:41:15 +00:00
Kacper Michajłow
5864b72d1a msg: improve term_disp_width to support unicode
All characters are assumed to be single-width. This is consistent with
the rest of the code and documentation.

Fixes: #13150
2024-01-04 13:41:06 +00:00
Kacper Michajłow
687372e2a2 ci/build-freebsd: use march=native for QEMU hosted build
This is workaround to not emit instructions that are broken with current
version of QEMU used in CI job.

Fixes SIGBUS on valid code when executed in QEMU caused by issue with
CVTPS2PD instruction.

QEMU issue:
https://gitlab.com/qemu-project/qemu/-/issues/1377

QEMU fix:
abd41884c5

Should be resolved after QEMU update to 8.2.0:
https://github.com/cross-platform-actions/action/issues/78
2024-01-04 11:44:22 +01:00
Kacper Michajłow
6e5fd52dde player/video: set video_out to NULL before broadcasting events
This avoids possible reference of video_out after destory.
2024-01-04 11:44:22 +01:00
Guido Cella
ab5b250343 command: allow changing --gpu-api and --gpu-context at runtime 2024-01-01 22:41:49 +01:00