Commit Graph

53394 Commits

Author SHA1 Message Date
Guido Cella
53554f521b DOCS/man/osc: update track middle-click action
Fixes 92a98f1ce2.
2024-12-12 17:48:53 +01:00
Kacper Michajłow
5897b66454 demux_mkv: limit EBML size to 64 MiB for fuzzing
OSS-Fuzz is limited to 2GiB of process memory, so allocating 512 MiB is
not working well and causing OOMs.
2024-12-12 01:45:19 +01:00
Kacper Michajłow
c14af4ebad options: disable playlist and include for fuzzing
Both of this options reads files, so there is not much to test there and
only creates problems with timeouts when too much is read.
2024-12-12 01:45:19 +01:00
Kacper Michajłow
9c81c67e2a m_property: stop processing after 10 properties even in skip cases
For OSS-Fuzz.

See: 2054d872d4
2024-12-12 01:45:19 +01:00
Dudemanguy
d33e54250e ao: correctly set state.playing for non-gapless audio after eof
The problem here is likely ao_alsa specific and has the same symptons as
what the previous commit fixed (audio not playing when the file changes
but the details are a bit different here and the sample rate does not
matter. When using gapless audio (the default), the core player
immediately marks the audio status as EOF after it starts draining and
allows the remaining audio buffers to play while it marches on. This
works fine. When not using gapless audio, it doesn't immediately set EOF
and instead waits for the audio to finish playing before it does
anything else. The problem is that ao_is_playing is always true so the
core waits forever thinking audio is still playing when it actually
isn't.

ao_play_data is what is in charge of setting the mp_pcm_state with it
calling out to the backend for additional help. Unfortunately, this
doesn't work for alsa because it's too dumb to signal the desired states
in this edge case so we have to help it a bit. The main thing to notice
here is that even though we can get EOF from a frame, there can still be
additional valid samples that compe after it. So we can't just
immediately quit after EOF is seen. The approach here is to simply save
if we got eof sometime in the past, wait until we get no more samples,
mark state.playing as false and then jump over to the eof code. This
will set p->playing to false as desired which allows the core code to
set EOF and finally we can go through the reset logic and actually play
audio for the next file.
2024-12-11 17:12:22 +00:00
Dudemanguy
a7f6460e7e player/audio: get rid of bogus early return in reinit_audio_filters
There is a condition here that is supposed to wait until the ao is
finished playing before it goes through the rest of this function and
actually starts the reinit of the audio chain. This is not needed
however and actually causes a bug. uninit_audio_out already takes the
gapless audio case into account and drains the audio before preceding.
There is no reason to bail here. Additionally, returning early here
actually breaks ao_alsa. ao_alsa is pretty dumb and not able to cope
with changing samplerates. It explictly needs to stop the PCM and then
start it again for it to work. The old code here ensured the ao would
never reinit itself and then would wait forever trying to play samples
with no actual data. Other AOs (pipewire and pulse) seem to be able to
cope with this and reinit themselves in other ways (didn't look in
detail). This change makes no difference for them. Note that in many
cases, this appeared to work on ALSA because there is a high likelihood
that your default audio device will choose a 48 kHz sampling rate and
thus your entire playlist is resampled to 48 kHz which avoids the
bug.

Fixes #15477.
2024-12-11 17:12:22 +00:00
Toad King
9f6faef60d sd_lavc: match video display aspect ratio on SD video in PGS subtitles
Previous fixes in bcc3d72 make subtitles on videos with non-square pixel
aspect ratios appear incorrect. This can happen on subtitles for SD
Blu-rays where the video resolution is 720x480 but the aspect ratio is
4:3. The scaling still applies when the video frame is cropped with
filters so the previous fix will still work.

Fixes #15415.
2024-12-11 18:11:35 +01:00
Guido Cella
2dd5bd4cd1 osc.lua: draw box layout below console
console is drawn below the OSC. This looks bad only with layout=box
because there is no user-data/osc/margins so it overlaps with it. Fix it
by using z -1 with box layout.

Follow up to 86d24b0 and 9c22d6b.
2024-12-11 17:51:16 +01:00
llyyr
7fffaf8557 vo: update base_vsync even for initial samples
This is still used for caclulating a/v sync and delay remaining even
for initial samples, so we should always update it to the actual vsync
for those initial samples so we have something to work with at least.

And if we receive bogus values, also reset it to 0 along with
prev_vsync.

Not having base_vsync set to _some_ value completely breaks
vsync_skip_detection, and mpv stays stuck in a permanent mistimed state
where every frame is marked as delayed and never recovers from it.
2024-12-11 16:42:13 +01:00
llyyr
bd915439d0 vo: use display clock to determine frame_end in display synced case 2024-12-11 16:42:13 +01:00
llyyr
84728fb5e9 vo: extract display synced frame end calculation
into get_display_synced_frame_end. Used in next commit.
2024-12-11 16:42:13 +01:00
Jisu Kim
e2014fb309 osc.lua: add option to enable fade-in effect
Introduced a new `fadein` option to control the fade-in effect for the OSC.
The default value is `no`, which disables fade-in. This option allows users
to enable a fade-in effect when the OSC appears. Updated documentation
accordingly.
2024-12-10 22:41:40 +01:00
Guido Cella
8d76ff79a3 console.lua: rename dimension variables
These are easier to read with _ between words. Also screenx/y could be
assumed to be display coordinates, so rename them to osd_w/h. They are
not named osd_width/osd_height to avoid Redefined local LSP warnings
with the ones in the upper scope.
2024-12-10 22:21:31 +01:00
nanahi
65328563e7 command: signal unavailable error when clipboard is unavailable
This allows clients to detect if the clipboard is unavailable,
or an error happened.
2024-12-10 14:20:08 +01:00
nanahi
e121c092b4 clipboard-vo: make logging verbose when clipboard is unavailable
It now only warns when the clipboard is implemented but get/set
failed. This is consistent with other properties like current-vo.
2024-12-10 14:20:08 +01:00
nanahi
e62503cb39 clipboard: add CLIPBOARD_UNAVAILABLE error code
This makes it possible to distinguish between unavailable
or unsupported, and error.
2024-12-10 14:20:08 +01:00
Guido Cella
7bae5b8d37 console.lua: clear completions before searching history 2024-12-10 14:18:51 +01:00
Guido Cella
7253b6c63d console.lua: remove code repetition to initialize matches 2024-12-10 14:18:51 +01:00
Kacper Michajłow
3df8b0b297 video/out/gpu/video: don't pass big structs by value when not needed 2024-12-10 14:14:09 +01:00
Kacper Michajłow
c00bd46684 m_option: put UPDATE_ flags at the beginning
Update flags are often updated, so make space for expand them. Reorder
all values to make it easier to add new ones, until there is no more
space.

Co-authored-by: Guido Cella <guido@guidocella.xyz>
2024-12-10 13:52:39 +01:00
Guido Cella
5dbaa69138 console.lua: add margin_{x,y} script-opts
Allow configuring the margins from the left bottom indipendently of
--osd-margin-{x,y}.

Fixes #15478.
2024-12-10 13:47:43 +01:00
Kacper Michajłow
db70ae6fa2 hwdec_vaapi: don't jump over variable init in try_format_upload 2024-12-10 10:17:34 +01:00
Kacper Michajłow
63e6dfba6e demux_mkv: fix memory leak of codec params
Fixes: 84ee84abb8
2024-12-09 20:46:48 +02:00
Guido Cella
0bb1659cd6 configfiles: refactor mp_get_playback_resume_config_filename()
This avoids duplicating fname when it is a URL.
2024-12-09 19:23:03 +01:00
Guido Cella
a5fa862a44 configfiles: don't use the basename of urls
With --ignore-path-in-watch-later-config the basename of files is used
for watch later files, but since 1d640c9887 this was checking the wrong
variable to determine if the file is a URL and thus also taking the
basename of URLs, when URLs should use the full path regardless of this
option.
2024-12-09 19:23:03 +01:00
Guido Cella
94135b1245 console.lua: don't override --osd-bold in completions
Respect the OSD bold style in completions printed after the selected
one.

Fixes #15452.
2024-12-09 19:21:33 +01:00
Kacper Michajłow
fe546c1841 w32_common: guard recursive call to mp_dispatch_queue_process
This is already done in WndProc, but the flag was not set if we exited
event loop and were processing mpv dispatch messages in fallback loop.

This fixes the case when Window is destroyed externally or otherwise
event loop fails for whatever reason. Calling vo_w32_uninit does call
DestroyWindow() through dispatch, which in turn calls WndProc, so we
need to guard recursive call.
2024-12-09 19:20:52 +01:00
Kacper Michajłow
4747865fef player/command: continue hook processing on errors
If a hook fails to invoke or a client has been removed during hook
processing, attempt to continue with the next hook if possible.

Before this commit, any failure during hook processing would cause the
hook processing to stop.

This issue can be reproduced when auto_profiles.lua registers an on_load
hook and exits afterward because no profiles are registered. In such a
state, the next hook would fail and not invoke.

There are many scenarios where a hook client may be broken,
unresponsive, or disabled, so it makes sense to continue processing
subsequent hooks.

The regression we observed was caused by e2284fba1 and 5dc404741, which
made auto_profiles.lua register hooks and then exit, leaving stale hooks
registered. However, the root cause is not limited to the
auto_profiles.lua case.

Fixes: #15465
2024-12-09 19:20:38 +01:00
Kacper Michajłow
e9af4092e9 player/configfiles: don't loop directory tree if not needed
If we already failed to generate fname, there is no need to try harder.
2024-12-09 19:20:25 +01:00
Kacper Michajłow
04eb51246f options: remove old compatibility definitions
This makes things more readable.
2024-12-09 19:19:50 +01:00
Kacper Michajłow
22bb5c2690 m_option: don't overlap UPDATE and M_OPT constant values
Fixes: e1d30c4c5a
2024-12-09 14:59:08 +01:00
Kacper Michajłow
baf528069a osdep/mac/meson.build: remove unused variables 2024-12-09 11:01:07 +01:00
Kacper Michajłow
8eea5902ba options/m_option: restore m_geometry_apply centering ability
This fixes geometry uses where it is expected to be centered. For
example this fixes video-crop option.

Fixes: e01eab4385
Fixes: #15398
2024-12-08 18:14:04 +01:00
Neko Asakura
8d20b72653 meson: use swiftc instead of swift for building 2024-12-07 14:27:16 +01:00
Guido Cella
90a7892545 DOCS/man/mpv: document that g-e selects disc titles
It is hard to discover otherwise.
2024-12-05 11:52:37 +01:00
Jan Ekström
1b1a8a3e4f demux_lavf: simplify replaygain export
* Early exit if there is no useful data in the AVReplayGain
  structure (FFmpeg does check that gain of at least one thing is
  not INT32_MIN, but leaves the peak unchecked so it can be zero).
* Less depth in the if structure.
2024-12-05 01:21:38 +01:00
Jan Ekström
1f86733bb3 demux_lavf: utilize side data getter for replaygain
This simplifies the code, not requiring a loop.

Moves the getter definition somewhat upwards to allow
for its usage in a function that was defined before it.
2024-12-05 01:21:38 +01:00
Misaki Kasumi
f75304957a io: support mp_make_wakeup_pipe on Windows 2024-12-05 01:20:31 +01:00
Kacper Michajłow
91f1f4ff43 demux_disc: add playlist filename to edition title if available 2024-12-04 14:51:53 +01:00
Kacper Michajłow
e9b5773bf9 stream_bluray: add STREAM_CTRL_GET_TITLE_PLAYLIST 2024-12-04 14:51:53 +01:00
Kacper Michajłow
de951c383b demux_disc: expose titles as editions
This allows to select DVD/Blu-Ray title easily. Titles are listed as
editions with their duration and number.

I wanted to include Angles also in this selection, but currently Angles
are not that well supported, so let's stick with titles and leave the
rest for the future changes.

We might migrate to lavf demuxer for DVD/Blu-Ray in the future, the mpv
implementation is rotted anyway.

Fixes #14586
2024-12-04 14:51:53 +01:00
Kacper Michajłow
d91eea20be stream_bluray: implement STREAM_CTRL_GET_TITLE_LENGTH 2024-12-04 14:51:53 +01:00
Kacper Michajłow
b594fc2d6c github/workflows: replace ruff-action with a maintained one
See: c413c59d2a
2024-12-04 14:48:37 +01:00
Guido Cella
78ee714fff console.lua: fix mp.input.get clients that don't specify completions
Actually update the rendered text when typing with an input.get client
that didn't specify a complete callback.

Fixes #15430, fixes 57b73f1af6.
2024-12-03 14:59:53 +01:00
Guido Cella
f7e6e30a49 aspect: add --video-recenter
This ignores --video-align-{x,y} when the video is smaller than the
window in the respective direction.

After zooming in, panning and zooming out, this is useful to recenter
the video in the window.

Unlike doing this by observing osd-dimensions in a script, this is done
before rerendering, so you don't see the image being rendered uncentered
for an instant after zooming out, before being rerendered centered.

Also update --video-align docs while at it.

This doesn't work well with --video-pan-{x,y} because you can move the
output rectangle far away from the image, and when zooming out pan is
abruptly reset to the center. It doesn't feel like natural like zooming
out after changing --video-align-{x,y}. So this commit doesn't set pan
to 0. Also this leaves a way to move scaled images within the window
even with --video-recenter.
2024-12-02 22:31:14 +01:00
Guido Cella
43f4568816 select.lua: select editions 2024-12-02 21:44:18 +01:00
Jan Ekström
17e62fcc61 demux/stheader: update lav_codecpar's comment
Was already being utilized by demux_raw, and now also created in
demux_mkv.
2024-12-02 21:03:21 +01:00
Jan Ekström
84ee84abb8 demux_mkv: propagate global stream side data via codecpar
The first AVPacket method has been deprecated in FFmpeg, and only
the HEVC decoder would read this information from there. The native
AV1 decoder as well as the libdav1d wrapper only support the newer
propagation method via codec context's side data. {ad,sd,vd}_lavc
call mp_set_avctx_codec_headers which copies the side data from
codecpar to codec context, so no changes are required on the
receiving end.
2024-12-02 21:03:21 +01:00
Jan Ekström
ba37142ba4 demux_lavf: stop global stream side data injection to AVPacket
This process has been deprecated since avformat 60.15.100 and
since avcodec 60.30.101 AV_PKT_DATA_DOVI_CONF has been read from
AVCodecContext's coded_side_data. Additionally, the HEVC decoder
is the only one which currently reads this side data from packets,
the native AV1 decoder as well as the libdav1d wrapper instead only
support the newer propagation method via codec context's side data.

How this currently is supposed to propagate is:
* demux_lavf copies the codec parameters into sh_stream's lav_codecpar.
* {ad,sd,vd}_lavc call mp_set_avctx_codec_headers that calls
  avcodec_parameters_to_context, which then sets global side data
  to the codec context.

As this logic is already in place, so no additional changes are required
for things to work and the deprecated function call can just be
cleaned up.

Ref: FFmpeg/FFmpeg@5432d2aaca
Ref: FFmpeg/FFmpeg@804be7f9e3
Ref: FFmpeg/FFmpeg@12e5116872
2024-12-02 21:03:21 +01:00
Guido Cella
063410fa04 console.lua: don't reinsert the next characters on complete
This avoids inserting the characters in front of the cursor again when
completing to text already in front of the cursor.

This is important after 2f271a92de made Enter automatically insert the
first completion.
2024-12-02 20:57:01 +01:00