Commit Graph

886 Commits

Author SHA1 Message Date
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
NRK 8bbcc87fee timer: remove MP_START_TIME
instead require mp_raw_time_ns() to not return 0, which all current
implementation already should follow.
2023-10-27 18:07:19 +00:00
Kacper Michajłow 729f2fed2c semaphore_osx: change mp_sem_timedwait to mp_time 2023-10-26 20:06:14 +00:00
Kacper Michajłow f659a60dfa semaphore_osx: don't overwrite global symbols 2023-10-26 20:06:14 +00:00
Kacper Michajłow 34d99840a5 timer: use MP_TIME macros 2023-10-26 16:49:38 +00:00
Kacper Michajłow 032b7de97f osdep/timer-win2: rename to timer-win32 2023-10-25 19:30:39 +00:00
llyyr 06c26e37ed osdep: fix clang warnings with `_FORTIFY_SOURCE`
This fixes warnings generated for `-Wunused-result` when mpv is built
with `-O1 -D_FORTIFY_SOURCE=1` or higher on clang since read/write
functions are declared with the `warn_unused_result` attribute.
Cast to void to avoid these warnings.
2023-10-24 22:49:22 +02:00
Kacper Michajłow 4de76ce87a osdep/meson: add libplacebo include dir to swift compile 2023-10-24 01:30:22 +00:00
NRK 8dc12f1d5b osdep: remove alignof emulation
it's unused. and since C11 is pretty freely used now, new code can just
use _Alignof or include <stdalign.h> directly.
2023-10-23 00:10:42 +00:00
Dudemanguy 94b67355c2 timer: drop ancient macOS fallback
macOS didn't support clock_gettime until 10.12 which was released
roughly 7 years ago. Since we're breaking support for ancient OSes
anyway, we might as well break some old macOS versions for fun. This
makes 10.12 the minimum supported macOS version.
2023-10-21 14:05:22 +00:00
sfan5 97afea441b win32/pthread: fix calculation error in pthread_cond_timedwait
closes #12699
2023-10-21 15:56:01 +02:00
Thomas Weißschuh dd13412986 win32/pthread: add support for pthread_mutex_trylock 2023-10-20 21:33:46 +02:00
Thomas Weißschuh 2181159158 threads: add support for pthread_mutex_trylock 2023-10-20 21:33:46 +02:00
NRK d05ef7fdc4 various: sort some standard headers
since i was going to fix the include order of stdatomic, might as well
sort the surrouding includes in accordance with the project's coding
style.

some headers can sometime require specific include order. standard
library headers usually don't. but mpv might "hack into" the standard
headers (e.g pthreads) so that complicates things a bit more.

hopefully nothing breaks. if it does, the style guide is to blame.
2023-10-20 21:31:09 +02:00
NRK 450a69b1d6 various: remove ATOMIC_VAR_INIT
the fallback needed it due to the struct wrapper. but the fallback is
now removed so it's no longer needed.

as for standard atomics, it was never really needed either, was useless
and then made obsolete in C17 and removed in C23.

ref: https://gustedt.wordpress.com/2018/08/06/c17-obsoletes-atomic_var_init/
ref: https://en.cppreference.com/w/c/atomic/ATOMIC_VAR_INIT
2023-10-20 21:31:09 +02:00
NRK 2070331f64 osdep: remove atomic.h
replace it with <stdatomic.h> and replace the mp_atomic_* typedefs with
explicit _Atomic qualified types.

also add missing config.h includes on some files.
2023-10-20 21:31:09 +02:00
NRK 2fa695c3f9 osdep: drop atomic fallback
even msvc (which mpv apparently doesn't support) supports C11 atomics
now. no need to carry around fallback with subtle semantic differences.
2023-10-20 21:31:09 +02:00
sfan5 3fb4eb2ba4 win32/pthread: try to fix system headers leaking through 2023-10-20 21:30:51 +02:00
sfan5 66c3110a85 win32/pthread: implement clock_gettime for high-res timer purposes
Also apply some fixes to pthread_cond_timedwait while we're at it.

Note that by using GetSystemTimePreciseAsFileTime here we lose support
for Windows 7. This is considered acceptable.
2023-10-20 21:30:51 +02:00
sfan5 9f147496b5 Revert "win32/pthread: don't convert time through unrelated timer"
This reverts commit 318b5471a1.

While it may work, changing these two functions in violation of their documented
behaviour for the sake of a shortcut is a hack that will spell disaster sooner or later.

This is a partial revert since the commit in question also contained a hidden
bugfix where it swapped the calculation order for time_rel.
2023-10-20 21:30:51 +02:00
Dudemanguy b8950f8d95 poll_wrapper: use the actual correct timeout for ppoll
It's not absolute time. Fixes #12660.
2023-10-17 15:05:33 +00:00
Dudemanguy 8f432b2e37 timer: remove microsecond timer functions
With the previous series of commits, all internal usage has been
replaced by the nanosecond functions. There's not really any point in
keeping these around anymore plus there are macros for unit conversions
now so we can just axe them. It's worth noting that mpv_get_time_us()
obviously still needs to work for API reasons, but we can just divide
mp_time_ns() by 1000 to get the same thing.
2023-10-16 15:38:59 +00:00
Dudemanguy 5cda1a5deb demux: convert cache updates to nanoseconds
As a bonus, we can remove the awkward and horribly named MP_SECOND_US.
2023-10-16 15:38:59 +00:00
Dudemanguy de9b800879 timer: add convenience time unit conversion macros
There's a lot of wild 1e6, 1000, etc. lying around in the code. A macro
is much easier to read and understand at a glance. Add some helpers for
this. We don't need to convert everything now but there's some simple
things that can be done so they are included in this commit.
2023-10-16 15:38:59 +00:00