Commit Graph

1143 Commits

Author SHA1 Message Date
Kacper Michajłow
d759e26fd0 libmpv: use correct header directory name
libmpv headers are installed to `mpv/`, so why are we pretending it is
`libmpv`?

Fixes documentation, libmpv meson dependency, tests.
2025-02-23 01:40:12 +01:00
der richter
76e3e8ae45 mac/dialog: release all input keys when modal steals key input
modal dialogs steal the key/mouse input and possibly eat corresponding
key up events when opening via key binding. this leads to key sequence
ends to not reported and key bindings not being triggered if no key up
event was triggered after closing the modal.
2025-02-19 16:10:25 +01:00
der richter
209521ff7c mac/dialog: remove delayed becomeFirstResponder() workaround
use the proper initialFirstResponder variable
2025-02-19 16:10:25 +01:00
Kacper Michajłow
fc2f176764 osdep/io: harden string conversions
We already abort if initial call fails, so there is no reason to not to
the same, even if we fully expect it wouldn't fail at this point.
2025-02-19 02:50:17 +01:00
Kacper Michajłow
2e0ccedfa1 win32-console-wrapper: don't use CRT in runtime wrapper
This is only needed for spawning main mpv process, there is no need to
spin CRT just to call main() and support basic memcpy.

Additionally adjust compilation flags to reduce the size of mpv.com.

This is the small binary using only kernel32 as dependecy now.

Stripped mpv.com built with clang 19.1.7 (x86_64-w64-windows-gnu)

Before:
   text    data     bss     dec     hex filename
   6982    7281       0   14263    37b7 mpv.com

After:
   text    data     bss     dec     hex filename
   1094    2894       0    3988     f94 mpv.com

Depending on compiler and options the size may vary. For example with
-flto and -Wl,-gc-sections it is:
   text    data     bss     dec     hex filename
    833     750       0    1583     62f mpv.com

but gc-sections were rejected as an default option before.

As a bonus add some error checking to this code.
2025-02-19 02:50:17 +01:00
Kacper Michajłow
30ea5da702 win32-console-wrapper: simplify error printing
No need for pointless prefix, print error directly. Don't use CRT
function. This will write only to console, but it's not meant to be
written to file anyway.
2025-02-19 02:50:17 +01:00
Kacper Michajłow
ea045b4755 osdep/timer-win32: add missing guards for ARM64
Does anyone compile libmpv for UWP?

Fixes: e908efe0b9
2025-02-18 10:47:03 +01:00
Kacper Michajłow
e908efe0b9 osdep/threads-win32: add implementation for mp_thread_cpu_time_ns() 2025-02-17 22:50:03 +01:00
Avi Halachmi (:avih)
40fb226cc2 common/stats: don't report cpu-time on unsupported platforms
On Windows and any other platform where cpu-time is unsuported,
previously the cpu-time was reported as 0, and now it's omitted
(at the perf-info property native value).

Code which process this report, like stats.lua, could not distinguish
between 0 which was due to unsupported platform, and "real" 0 which
indicates zero cpu activity in this poll-period.

In stats.lua this resulted in a whole lot of empty cpu graphs,
including one for every loaded script.

Now cpu-time is excluded from the report on unsupported platforms.
Real-time is obviously still being reported where requested.

Implementation wise, this is slightly hacky, by literally only
excluding the cpu-time nodes from the report itself, while keeping
all the other cpu-tinme code intact.

A more correct solution might be to identify support at compile
(configure) time, and no-op the relevant code if needed.

However, stats.c is already hacky in parts, and there's no real cost
to keeping the code active even if the result is excluded at the
report, and it's also way simpler and less bug prone. So be it.
2025-02-17 22:50:03 +01:00
Dudemanguy
ef3e6bebe4 language-posix: replace '_' subtag separator with '-'
Internally, mpv uses '-' as a separator for language codes like
specifying the region/variant for the language. However, the posix
environment variables for this separate using a _. Since
5009e13431, support for the _ separator
was dropped which meant that --subs-match-os-language actually didn't
work on linux/bsd at all (mac has its own separate implementation).
Instead of adding _ back to the function, it makes more sense to just
replace _ with - while we parse through the languages since this
implementation of mp_get_user_langs is the only one that separates with
_.
2025-02-16 00:47:13 +00:00
der richter
f94b44c8e5 mac/menu: add support for initial directory 2025-02-15 16:22:52 +00:00
der richter
ebb0fe68d6 mac/dialog: add support for title, file selection and initial directory 2025-02-15 16:22:52 +00:00
der richter
c75779d3b4 mac/swift: move isUrl check to String extension 2025-02-15 16:22:52 +00:00
der richter
6b0e4f7b91 mac/dialog: add file extension filtering for open dialogs
use the configured file extensions from options to filter.
2025-02-15 16:22:52 +00:00
der richter
c2106d1894 mac/option: add MPOpts root options 2025-02-15 16:22:52 +00:00
der richter
21732787b8 mac/dialog: move dialog creation into its own class 2025-02-15 16:22:52 +00:00
Dudemanguy
956cb2c49f various: simplify mp_normalize_path usage
If a talloc_ctx was being made solely for a onetime usage of getting a
normalized string, we can now just pass NULL instead and free the string
directly to make things easier.
2025-02-01 16:12:03 +00:00
Kacper Michajłow
79e29787de osdep/terminal-unix: fix stop_cont_pipe leak
mpv_create/mpv_destroy would leak those.
2025-01-29 22:27:11 +01:00
Kacper Michajłow
d64095bd7e osdep/io: map ftell to int64_t version on win32
Note that all mpv code expects 64-bit offsets already. And we set
_FILE_OFFSET_BITS=64 unconditionally. Also this mirrors lseek() that we
already have wrapped in similar way.
2025-01-26 22:10:00 +01:00
Kacper Michajłow
b01e1ab61a osdep/io: add ftruncate for win32
Trivial wrapper around _chsize_s() to return -1 on errors always.
_chsize_s() returns errno value. At the same time errno is set to the
same value.

FILE_WRITE_DATA has to be added in append mode, because _chsize_s()
requires write permissions, not only append. We lose atomic append, but
we follow POSIX here, so that's fine, I guess.
2025-01-26 22:10:00 +01:00
der richter
64aeb4273d mac/app: make const char pointers to const pointers
they were meant to be immutable. imported in swift as mutable pointer,
which leads to errors with the strict concurrency in swift 6.

make the pointers const.
2025-01-04 17:04:21 +01:00
der richter
d03ce00127 mac/app: make re-assignment of complex macros const
they were never meant to be mutable and are imported as mutable vars
in swift. that causes errors with the strict concurrency in swift 6.

make them const/lets and immutable.
2025-01-04 17:04:21 +01:00
Kacper Michajłow
59d1dc43b9 various: fix typos 2025-01-04 15:59:49 +02:00
der richter
c1e0e32453 mac/remote: use swift closure instead of obj-c selector bridging
it's unnecessary to use the overhead of an obj-c selector and the
resulting bridging.
2025-01-04 13:33:15 +01:00
der richter
8af05d4fa1 mac/swift: fix global variables for upcoming swift 6 concurrency
fixes problems with upcoming features DisableOutwardActorInference,
GlobalConcurrency and InferSendableFromCaptures for swift 6 strict
concurrency. enabled with -enable-upcoming-feature flag.
2025-01-02 15:12:28 +01:00
der richter
1551cef54e mac/remote: add Quick Look thumbnail as cover fallback
since we load covers/images directly in a our own thread and the quick
look thumbnailing also works asynchronously on its own thread, we need
sync/coordinate both threads. otherwise it would be possible that a
cover from a different file could overwrite the cover of the current
file.

to prevent this every cover generation has a unique timestamp and only
covers for the last cover timestamp will ever be shown.

we are also not interested in icon type thumbnails, since those are just
generic file type icons.

quick look thumbnails can only be generated if quick look can read those
files. files unknown to macOS don't work out of the box and you need to
install a quick look extension for this, "QuickLook Video" for mkv.
2024-12-31 14:44:16 +01:00
Misaki Kasumi
e325959980 subprocess: fix reset_signals_child missing last signo 2024-12-31 10:16:50 +01:00
der richter
4dbf81c94c mac/title: use enum for material values instead of generic integers 2024-12-28 14:30:41 +01:00
der richter
4063cdf20b mac/title: use enum for appearance values instead of generic integers 2024-12-28 14:30:41 +01:00
der richter
cd9fa6daf0 mac/title: remove old libmpv color setter fallback 2024-12-28 01:46:41 +01:00
der richter
bba198a713 mac: use isBundle function instead of manually checking bundle usage 2024-12-26 15:00:57 +01:00
der richter
026f1fb61d clipboard-mac: add macOS clipboard backend 2024-12-24 16:11:45 +01:00
der richter
e8ecc7d9d9 osdep/mac/meson.build: dynamically add features to swift build flags
similar to how our config.h is created the feature flags added to the
swift build should be generated from our features array, instead of
manually adding those when needed.

this prevents errors when forgetting to add any needed flags or remove
obsolete ones.
2024-12-24 16:10:52 +01:00
der richter
e785296a1c cocoa-cb: use new ambient-light property and remove old libmpv usage 2024-12-21 16:15:44 +01:00
Kacper Michajłow
baf528069a osdep/mac/meson.build: remove unused variables 2024-12-09 11:01:07 +01:00
Neko Asakura
8d20b72653 meson: use swiftc instead of swift for building 2024-12-07 14:27:16 +01:00
Misaki Kasumi
f75304957a io: support mp_make_wakeup_pipe on Windows 2024-12-05 01:20:31 +01:00
der richter
11186374a0 mac/option: explicitly include and define type of global init variable
the mpv_global struct is a public struct defined in common/global.h. in
the case that this header is included directly or indirectly into our
swift bridging header, code that uses that struct as an OpaquePointer
will fail to build, because swift would now be aware of its actual type.

preemptively include the header and properly define the type to prevent
such errors in the future.

i also checked all other usages of OpaquePointers and this is the only
case where this is relevant.

See e1d30c4 and 4ff9f50 as reference
2024-12-01 19:25:37 +01:00
Guido Cella
b9e6030053 command: highlight selected list items with color
Instead of printing circles in show-text ${playlist}, ${chapter-list}
and ${edition-list}, introduce --osd-selected-color and
--osd-selected-outline-color to reduce clutter, make the selected item
easier to differentiate, and have visual consistency with select.lua.

The defaults are taken from the style of the selected item in the
console. These new options are also used there, replacing the hardcoded
styles. Due to being user-configurable, selected item styles are changed
to take priority over default item styles.

The default selected style is yellow and bold. The bold (hardcoded)
allows differentiating the selected item with color blindness. There is
also a separate --osd-selected-outline-color option defaulting to black,
since without it if the user changes --osd-outline-color yellow text
becomes unreadable without a black border. --osd-selected-back-color is
omitted for now.

Text and background colors are inverted for the selected item in the
terminal. This is hardcoded, adding an option is overkill.

A disadvantage of this commit is that if you run print-text ${playlist}
with a VO, the selected style ASS is printed to the terminal (but ASS
printed in the console is interpreted). This commit avoids printing the
reset ASS sequence for non-selected items to reduce clutter in this
case.
2024-11-27 15:37:42 +01:00
der richter
45c1c58680 mac/compat: fix compatibility for deployment targets lower than SDK ver
the swift parts can't be nicely encapsulated in the compat file because
it lags proper target version compile time checks.

Fixes #15292
2024-11-18 19:28:35 +01:00
der richter
91d4e6f937 mac/type: change never mutated variable to let 2024-11-05 18:34:15 +01:00
der richter
c80757d782 videotoolbox: silence OpenGL deprecation warnings 2024-11-05 18:34:15 +01:00
der richter
84adbd9d35 ao_coreaudio: fix CoreAudio deprecations 2024-11-05 18:34:15 +01:00
der richter
6f009a91a6 mac/common: fix light sensor deprecations 2024-11-05 18:34:15 +01:00
averne
32bcaf865b osdep/terminal: fix dummy implementation
c2ed2e7 introduced the terminal_set_mouse_input function to various terminal
backends, but overlooked the dummy backend.
This causes linking errors when trying to build on platforms with no terminal,
as vo_kitty and vo_tct are unconditionally enabled and make use of that
function.
2024-11-02 20:05:11 +01:00
Guido Cella
99e4979b01 mac/menu: use show-text instead of old osc script messages
1a558bf5c2 made osc-*list script messages aliases to show-texting the
relative properties, so use show-text directly in the menu. Also
increase the duration to be the same as the OSC buttons because the
default of 1 second is too short.
2024-10-26 20:09:57 +02:00
Kacper Michajłow
4045fac980 osdep/io: remove duplicated code for error to string conversion
This also removes \n from the end of the string, which shouldn't be
present in this string.
2024-10-22 18:53:18 +02:00
der richter
37159a8ee0 mac/remote: show external covers in Now Playing Info Center 2024-10-19 17:20:43 +02:00
der richter
8cc3160f71 mac/event: add MPV_FORMAT_NODE handler 2024-10-19 17:20:43 +02:00
der richter
f866893c9c mac/type: add mpv_node type conversion helpers 2024-10-19 17:20:43 +02:00