Commit Graph

909 Commits

Author SHA1 Message Date
Kacper Michajłow e2e75906da io: add mp_save_file
Move from vo_gpu_next.c to io.c and return result.
2024-01-31 15:38:21 +00:00
Kacper Michajłow 19a6b84915 osdep/timer: update documentation and test for mp_time_ns
No longer true after 8bbcc87fee.
2024-01-26 03:28:55 +00:00
Kacper Michajłow 52cabca4e5 osdep/io: expand path before LoadLibrary
Fixes compatibility with loading scripts from relative config paths.

Fixes #13212
2024-01-22 14:41:46 +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
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
sfan5 9565675488 various: use correct PATH_MAX for win32
In commit c09245cdf2
long-path support was enabled for mpv without actually
making sure that there was no code left that used the
old limit (260 Unicode chars) for buffer sizes.
This commit fixes all but one case.
2023-12-27 22:55:56 +01:00
sfan5 f57ec94d9f osdep: clarify and rename a constant on win32
This is about the maximum filename not path length.
2023-12-27 22:55:56 +01:00
Ikko Eltociear Ashimine dd48a53b65 various: fix capitalization of 'GitHub' 2023-12-27 22:11:58 +01:00
Andarwinux e832f4969f win32: opt in to the windows segment heap
ref: https://learn.microsoft.com/en-us/windows/win32/sbscs/application-manifests#heaptype

Improves demuxer cache recycling speed at the cost of a slight CPU usage increase.
SegmentHeap is supported in Windows 10, version 2004 (build 19041) and later.
2023-12-22 16:36:31 +01:00
stax76 c09245cdf2 win32: support long file paths 2023-12-21 17:40:45 +01:00
Guido Cella 17be6e1990 terminal-unix: enable the cursor after ctrl+z
24270b8587 disabled the cursor while mpv is running, but if you send mpv
to the background, it is not re-enabled until you run bg, and not even
after that if mpv is paused. Fix this by enabling the cursor from the
SIGTSTP handler.
2023-12-18 15:03:40 +00:00
der richter c661435648 mac: add support for drag-and-drop option 2023-12-15 16:59:52 +01:00
nanahi 79068baf43 win32: properly handle WM_XBUTTONUP and WM_XBUTTONDOWN
According to MS documentation, an application should return TRUE from
WM_XBUTTONUP and WM_XBUTTONDOWN if it processes these messages.
DefWindowProc generates the WM_APPCOMMAND message when it processes the
WM_XBUTTONUP message, so if an application properly handles WM_XBUTTONUP
messages, extra WM_APPCOMMAND messages won't be generated.

Because mpv doesn't properly handle these messages,
WM_XBUTTONUP causes APPCOMMAND_BROWSER_BACKWARD to be generated, resulting
in duplicated keys and improper fix 438ead7a, which prevents the processing
of the appcommand from sources other than mouse clicks.

Fix this by following the documentation, and the back and forward
appcommands can be added.
2023-12-06 11:07:37 +01:00
der richter f551a9da34 mac: report modifier keys on precise scrolling
modifier keys weren't reported when using the trackpad to scroll.

Fixes #11195
2023-12-02 14:59:59 +01:00
Dudemanguy f7402ff466 Reapply "osdep/meson: add libplacebo include dir to swift compile"
It's not actually related to libplacebo wrap stuff and the swift compile
command needs this to get the right libplacebo include path.

This reverts commit b9d392ecd9.
2023-11-27 15:00:35 -06:00
Dudemanguy b9d392ecd9 Revert "osdep/meson: add libplacebo include dir to swift compile"
This is not needed since we removed the libplacebo wrap not too long
after this commit.

This reverts commit 4de76ce87a.
2023-11-27 20:44:07 +00:00
der richter 3f2bc2e535 mac: fix libmpv usage without embedding
NSApp is only an Application when initialised from mpv itself. when used
via libmpv an Application is never initialised and mpv would always
immediately exit.

make the retrieval of the vo and mac options static so they can be
retrieved in all cases.

Fixes #12518
2023-11-25 19:04:07 +01:00
der richter 5aac4c1aee mac: cleanup some unused and unneeded code 2023-11-25 19:04:07 +01:00
Kacper Michajłow bdf4dca505 osdep/io: add PRINTF_ATTRIBUTE for printf overrides 2023-11-25 12:38:20 +01:00
Kacper Michajłow ed107c4116 meson: adjust win32 defines
- Don't define _GNU_SOURCE on Windows, no need
- Define WIN32_LEAN_AND_MEAN to strip some unneded headers from
  windows.h
- Define NOMINMAX and _USE_MATH_DEFINES as they are common for Windows
  headers
2023-11-25 12:38:20 +01:00
Kacper Michajłow ab8cc64b19 osdep/macosx: add default switch cases to suppress Wswitch 2023-11-24 10:05:09 +01:00
der richter eb71aa059a mac: add rotation menubar entries 2023-11-20 23:16:43 +01:00
Kacper Michajłow d30432ea31 win32: don't jump over variable init with goto
Those variables are accessed after jump.
2023-11-18 23:55:28 +00:00
Daniel Brookman aa8af2e66b osxbundle: remove mpv-bundle symlink to allow code signing
Apps on Apple silicon have to be codesigned to run, but you can't
codesign bundles that have a symlink for the main executable.

The "mpv-bundle" symlink was used as the bundle's main executable
because it makes the execution name of the binary different.
Launch Services runs the CFBundleExecutable key from Info.plist when
launching a bundle, so by comparing the execution name to the name of
the symlink, you can check if that's how the binary was launched.

This replaces that detection method by moving the MPVBUNDLE
environmental variable into Info.plist. Launch Services will set
anything in LSEnvironment as environmental variables before launching
the bundle, so we're able to check for it instead of needing to
differentiate the execution name of the binary.

Fixes #12116
2023-11-15 23:08:11 +01:00
Kacper Michajłow 438ead7a3d osdep/w32_keyboard: remove duplicated MP_KEY_BACK mapping
MP_MBTN_BACK is already mapped, the appcmd duplicates this.

Fixes: #12768
Fixes: 8301906
2023-11-11 03:34:00 +00:00
der richter a54cc02341 mac: change display name retrieval to localizedName NSScreen property
the old displayName property via the IODisplay API is not working
anymore on ARM based macs and was broken in at least one other case.

instead we use the new localizedName property introduced in 10.15 of the
NSScreen. we don't need any backwards compatibility since 10.15 is the
oldest version we support now.

configs and scripts that use the options and properties fs-screen-name,
screen-name or display-names need to be adjusted since the names could
differ from the previous implementation via the IODisplay API.

Fixes #9697
2023-11-10 14:30:32 +01:00
sfan5 8f8b63d622 osdep/io: implement rename() wrapper
This is needed to provide the POSIX behaviour of transparently
overwriting existing paths.
2023-11-10 11:26:10 +01:00
Kacper Michajłow 7d86807a5f vo: don't sleep 1ms always when requested time is in the past
Fixes a899e14b which changed clamp from 0 to 1 ms which effectivelly
introduced 1ms sleep always, even if requested until_time_ns is in the
past and should request 0 timeout.

While at it also fix mp_poll wrapper to respect negative timeout which
should mean infinite wait.

Also keep the 37d6604 behaviour for very short timeouts, but round only
the ones > 100us, anything else is 0.

Fixes: a899e14b
2023-11-09 21:31:58 +00:00
der richter 23de1deaaa mac: remove runtime checks and compatibility for macOS older than 10.15
we stopped supporting macOS older than 10.15 and hence can remove all
the unnecessary runtime checks and compatibility layers.
2023-11-09 18:12:25 +00:00
Dudemanguy a5bf211e12 meson: remove several macos-10-* build options
These have been build options since the waf build, but that doesn't
really make sense. The build can detect whatever macOS sdk version is
available and then use that information to determine whether to enable
the features or not. Potentially disabling multiple sdk versions doesn't
really make any sense. Because f5ca11e12b
effectively made macOS 10.15 the minimum supported version, we can drop
all of these checks and bump the required sdk version to 10.15. The rest
of the build simplifies from there.
2023-11-09 18:12:25 +00:00
Thomas Weißschuh 4a134f441d audio: introduce ao_read_data_nonblocking()
This behaves similar to ao_read_data() but does not block and may return
partial data.
2023-11-08 20:26:23 +01:00
Kacper Michajłow a5c32ea52e threads-win32: add comment about local decl of a function 2023-11-08 04:32:10 +00:00
Kacper Michajłow 2ae56e78dd threads-win32: support UWP in mp_thread_set_name 2023-11-08 04:32:10 +00:00
Kacper Michajłow fa0929bf71 osdep/threads-posix: use CLOCK_MONOTONIC if supported 2023-11-08 04:32:10 +00:00
Kacper Michajłow 0a6c179026 osdep/timer-linux: check clock availability on init 2023-11-08 04:32:10 +00:00
Kacper Michajłow a7186777de threads: unbreak mpv on builds without asserts
Also remove duplicated macro.

Fixes: #12818 #12820
2023-11-06 04:14:49 +00:00
Kacper Michajłow e268dead30 win32/pthread: remove unused code 2023-11-05 17:36:17 +00:00
Kacper Michajłow 71e888c2a0 timer: remove unused code 2023-11-05 17:36:17 +00:00
Kacper Michajłow 751790c2b3 threads: remove unused code 2023-11-05 17:36:17 +00:00
Kacper Michajłow f75fe33da7 threads: rename threads.c to threads-posix.c 2023-11-05 17:36:17 +00:00
Kacper Michajłow 1e0aaab78c threads: move pthread debug to threads-posix.h
And remove redundant define while at it.
2023-11-05 17:36:17 +00:00
Kacper Michajłow 56d35da180 mp_thread: add win32 implementation 2023-11-05 17:36:17 +00:00
Kacper Michajłow 55ed50ba90 mp_thread: prefer tracking threads with id
This change essentially removes mp_thread_self() and instead add
mp_thread_id to track threads and have ability to query current thread
id during runtime.

This will be useful for upcoming win32 implementation, where accessing
thread handle is different than on pthreads. Greatly reduces complexity.
Otherweis locked map of tid <-> handle is required which is completely
unnecessary for all mpv use-cases.

Note that this is the mp_thread_id, not to confuse with system tid. For
example on threads-posix implementation it is simply pthread_t.
2023-11-05 17:36:17 +00:00
Kacper Michajłow 174df99ffa ALL: use new mp_thread abstraction 2023-11-05 17:36:17 +00:00
Kacper Michajłow 3a8b107f62 threads: add new mp_thread abstraction
This will allow to avoid hacky pthreads symbols/header override.

Inspired by pl_thread from libplacebo.
2023-11-05 17:36:17 +00:00
Guido Cella 040622f6b7 various: remove trailing whitespace 2023-10-30 16:45:47 +00:00
Dudemanguy 891efca9d7 timer-linux: fallback to CLOCK_MONOTONIC instead of timespec_get
CLOCK_MONOTONIC_RAW is linux-specific (macOS later supported it but it
has its own timer code) and not neccessarily available everywhere like
on BSDs. It makes sense to prefer it because mpv does a lot of
measurements at small intervals (e.g. every frame) so theoretically it
should be more accurate. However if the OS doesn't have it, fallback to
CLOCK_MONOTONIC instead which is almost exactly the same and very widely
supported across unix-like systems. This clock is technically optional
according to POSIX, but any half-decent OS supports it anyway (sorry
Solaris users). As a benefit, we now know that the clock from mp_time is
always monotonic.
2023-10-27 23:19:07 +00:00
Kacper Michajłow cb829879af mp_threads: rename threads for consistent naming across all of them
I'd like some names to be more descriptive, but to work with 15 chars
limit we have to make some sacrifice.

Also because of the limit, remove the `mpv/` prefix and prioritize
actuall thread name.
2023-10-27 23:18:56 +00:00