Commit Graph

1057 Commits

Author SHA1 Message Date
der richter 1acca1d3c4 mac/apphub: move app icon into AppHub
split up AppHub header in obj-c and c parts and make it a bidirectional
bridging.
2024-03-29 14:20:40 +01:00
der richter 86aea966d9 mac: cleanup mac headers and include preprocessors 2024-03-29 14:20:40 +01:00
der richter a46ce9e28c mac/event: only initialise an EventHelper when necessary 2024-03-24 23:03:48 +01:00
der richter b77d5386c3 mac/touchbar: use AppHub directly instead of the singleton 2024-03-24 23:03:48 +01:00
der richter 37b2e59787 mac/remote: use AppHub directly instead of the singleton 2024-03-24 23:03:48 +01:00
der richter 6846338cf2 mac/touchbar: use EventHelper for event handling
also remove remaining old event handling.
2024-03-24 23:03:48 +01:00
der richter f9618ea487 mac/touchbar: move touch bar into AppHub 2024-03-24 23:03:48 +01:00
der richter 3e6c931d90 mac/remote: use EventHelper for event handling 2024-03-24 23:03:48 +01:00
der richter 4107d29c90 mac/touchbar: fix devision by 0 2024-03-24 23:03:48 +01:00
der richter 6d767537d4 mac/remote: fix devision by 0 2024-03-24 23:03:48 +01:00
der richter 5ab3060961 cocoa-cb: use EventHelper for event handling 2024-03-24 23:03:48 +01:00
der richter 2a4bf7ca22 cocoa-cb: use a separate mpv_handle for cocoa-cb to simplify shutdown 2024-03-24 23:03:48 +01:00
der richter 7e07e1a087 mac/apphub: migrate remaining events functionality to new AppHub
add new app_bridge objc file for bridging between mpv core and app
functionality. replace old EventsResponder singleton with AppHub.

another step to clean up all App functionality and have one central
place for it.
2024-03-24 23:03:48 +01:00
der richter deb9d30e90 mac/event: add helper to subscribe to mpv events and property changes
preparation to remove duplicate code from all classes that implement
their own observer loops.
2024-03-24 23:03:48 +01:00
der richter 9cee44147a mac/libmpv: remove unused functions 2024-03-21 18:33:15 +01:00
der richter 9e03ab5e1e mac/option: remove now unused computed option variables 2024-03-21 18:33:15 +01:00
der richter 204e3f0df6 mac/option: rename option structs to properly represent their content
also optimise option cache setup.
2024-03-21 18:33:15 +01:00
der richter f72dfd48d0 mac/libmpv: remove mac option handling in favour of option handler
since the option handler is not optional anymore and available on init
in cocoa-cb we don't need to duplicate this functionality in libmpv
anymore.
2024-03-21 18:33:15 +01:00
der richter b480daad88 mac/option: make option helper none optional
gets rid of some unwrapping boilerplate and nil coalescing operators.
2024-03-21 18:33:15 +01:00
der richter 6defd49aa1 mac/option: make option helper vo struct independent 2024-03-21 18:33:15 +01:00
der richter 90c534a821 mac/option: optimise option pointer access 2024-03-21 18:33:15 +01:00
der richter 2d9be04c00 mac/option: remove unused and obsolete variables 2024-03-21 18:33:15 +01:00
der richter dc5059d027 mac/option: move option functionality from mpv helper to option helper
delete now empty mpv helper
2024-03-21 18:33:15 +01:00
der richter 283d0877c4 mac/type: move c<>swift type bridging into a dedicated type helper 2024-03-21 18:33:15 +01:00
nanahi aff376e066 win32: increase hires timer resolution
timeBeginPeriod() only allows setting minimum timer resolution
to 1 ms. However, modern x86 platforms support a minimum timer
resolution of 0.5 ms. Use NtSetTimerResolution() instead for
the increased resolution, which can be set with MPV_HRT_RES.

Additionally, change the units of mp_start_hires_timers(),
mp_end_hires_timer(), MPV_HRT_RES, and MPV_HRT_MAX to nanoseconds,
in accordance with other functions used in timer.h.
2024-03-19 20:23:25 +01:00
Kacper Michajłow bfd016d101 win32: avoid multi byte string to wide conversion if not needed 2024-03-19 19:58:09 +01:00
Kacper Michajłow fc55f355fc win32: add puts/fputs wrappers 2024-03-19 19:58:09 +01:00
Kacper Michajłow 3372e17d51 win32: optimize mp_vfprintf a little
- remove redundant strlen/wcslen
- reuse allocated temporary buffers

The difference is not big, but it satisfies me to remove those
redundancies.
2024-03-19 19:58:09 +01:00
Kacper Michajłow 8ee25db71f win32: cache GetConsoleMode state for stdout/stderr
GetConsoleMode() can be quite slow and in mpv the mode never changes, so
we can just check it once.

Fixes performance when writing lots of logs to terminal.
2024-03-19 19:58:09 +01:00
Kacper Michajłow 7bdd673a72 win32: don't touch buffering options 2024-03-19 19:56:25 +01:00
Kacper Michajłow fe29152d06 win32-console-wrapper: fix printf specifiers
%s is evaluated as wchar_t only in "Windows classic" semantic. It is not
C standard compliant.

%ls is compatible with both and means the same wchar_t format.

This commit fixes error output from mpv.com.

See: https://devblogs.microsoft.com/oldnewthing/?p=102823
2024-03-19 19:56:25 +01:00
Kacper Michajłow c3843d79de win32: don't pass std handles if they are attached to console
This is default behavior to attach to existing console, passing custom
handles is useful if we want to replace them, but in case they are
already attached to console we want to attach to console directly.

In theory, it should work out of the box because "console-like" handles
should be managed by Windows internally, which works for INPUT and
OUTPUT, but in certain cases, not for ERROR. This allows using VT
features in those cases for stderr too.
2024-03-19 19:56:25 +01:00
nanahi aa08e304c4 Revert "osdep/io: ignore 'x' mode for mp_fopen"
This flag is a GNU extension in C99, but was standardrized in C11,
so mpv should be able to use it. fopen is wrapped on win32 so
non-compliant MSVCRT.dll isn't a concern.
Since the upcoming commit uses this feature it can be brought back.

This reverts commit c36e051470.
2024-03-19 19:30:27 +01:00
nanahi d2bbd7a531 win32: implement shell link target resolving
Adds a function to resolve the target of a shell link (Windows shortcut)
for use by other parts of mpv.
2024-03-19 11:34:00 +01:00
nanahi 465f405703 osdep/main-fn-win: fix implicit conversion warning 2024-03-19 08:58:18 +01:00
nanahi fbea9607be osdep/threads: fix warning: initializer element is not constant 2024-03-19 08:58:18 +01:00
der richter bf1c8acdac mac/touchbar: simplify item and view creation 2024-03-18 20:29:27 +01:00
der richter 9f68214a06 mac/touchbar: optimise time item update 2024-03-18 20:29:27 +01:00
der richter d7cc5cdec1 mac/touchbar: optimise constraint calculation 2024-03-18 20:29:27 +01:00
der richter ef82ef0bb5 mac/touchbar: use DateComponentsFormatter for time formatting 2024-03-18 20:29:27 +01:00
der richter be49f4fe20 mac/touchbar: simplify update items logic 2024-03-18 20:29:27 +01:00
der richter 647bf5d0ba mac/touchbar: take playback speed into account for rate limiting 2024-03-18 20:29:27 +01:00
der richter c8088d801a mac/touchbar: rewrite touch bar in swift 2024-03-18 20:29:27 +01:00
sfan5 ead9f892b3 various: use static assertions where appropriate 2024-03-17 20:04:04 +01:00
der richter 2a36ed9abd mac/input: optimise scroll wheel event handling 2024-03-16 15:29:27 +01:00
der richter a4eddf742d mac/input: move scroll wheel event handling into input helper 2024-03-16 15:29:27 +01:00
der richter 9a4c673dd7 mac/input: optimise mouse movement enabled check 2024-03-16 15:29:27 +01:00
der richter 53722a4082 mac/input: fix switched mouse forward and back button 2024-03-16 15:29:27 +01:00
der richter db4eac140d mac/input: move mouse event handling into input helper 2024-03-16 15:29:27 +01:00
der richter 474e213f52 mac/input: add missing special keys 2024-03-14 23:33:15 +01:00
der richter 556cb7d6a4 mac/input: add simplified mp_keymap init 2024-03-14 23:33:15 +01:00
der richter 4d8ea338de mac/input: remove wrongly mapped modifier keys 2024-03-14 23:33:15 +01:00
der richter 3ef3bbf93d mac/event: move key event handling to input helper and optimise it 2024-03-14 23:33:15 +01:00
der richter 5482eecb8a mac/input: define AltGr mask as static NSEvent.ModifierFlags variable
this makes it possible to properly test for those modifiers in a proper
swift like way.
2024-03-14 23:33:15 +01:00
der richter 18fb71498b mac/events: remove redundant functions and optimise input helper usage
some redundant functions that jump through hoops.
2024-03-14 23:33:15 +01:00
der richter 055e9cd93e mac/helper: move input ctx related functionality into new input helper
also make functions thread safe.
2024-03-14 23:33:15 +01:00
der richter f3e5fea4f5 mac/events: move input ctx related functionality into new input helper
preparation for mac/events cleanup and single responsibility principle.
all functions are thread safe.
2024-03-14 23:33:15 +01:00
der richter 8a37f0f693 mac/menu: add explicit menu type instead of an inferred type
with the use of an explicit type we can removed inferred type checks
like separators/services menu by name or menus by sub configs.
2024-03-07 01:03:52 +01:00
der richter 16ea688115 mac/menu: make menu creation recursive to allow nested submenus
also makes menu creation cleaner and more obvious.
2024-03-07 01:03:52 +01:00
der richter 4eb58f6ea7 mac/menu: move conditional Bundle menu items into config
only add the "Show log File…" menu item config when invoked from the
bundle, instead of testing on menu item creation. this is similar to the
touch bar menu items now.
2024-03-07 01:03:52 +01:00
der richter 73e494a237 mac/menu: keep track of menu items with dynamic actions
keeping track of the dynamic menu items lets us directly access them by
key. we don't need to search in the config array for the right config
and menu item.
2024-03-07 01:03:52 +01:00
der richter 8d4329a710 mac/menu: merge file and url config properties
a file path is basically an URL. both are also handled as URL objects
in our code.
2024-03-07 01:03:52 +01:00
der richter 46a9e8c130 mac/menu: properly guard playlist array access 2024-03-07 01:03:52 +01:00
der richter 30eab4b933 mac/menu: attach menu config to menu item for direct access
add a config property to the menu items, so we don't need to search in
the config array for the right config.
2024-03-07 01:03:52 +01:00
der richter 95d08df7a7 mac/menu: replace app.command usage with event.command 2024-03-07 01:03:52 +01:00
der richter 37990597c7 mac/menu: fix touch bar menu item
the check broke when the runtime check was removed, eg the menu item was
never added to the menu. since we only add the menu item to the config
when touch bar support is available the check is completely unnecessary.
2024-03-07 01:03:52 +01:00
der richter 035906dad5 mac/menu: rename Preferences to Settings for consistency with macOS 2024-03-07 01:03:52 +01:00
der richter ad0573ff8e mac/menu: remove duplicate key assignment Undo/Zoom
this key is already assigned to Undo.
2024-03-07 01:03:52 +01:00
der richter eadd85a6ac mac/menu: optimise loading files function
don't save files in a temporary array and use an in place mapping.
2024-03-07 01:03:52 +01:00
der richter cb807ff063 mac/menu: replace deprecated openFile() usage 2024-03-07 01:03:52 +01:00
der richter 996ec6feca mac/menu: remove unnecessary alert config fields and alert
the config folder is created by mpv if it does not exist, so the last
alert is unnecessary.

also change config path priority.
2024-03-07 01:03:52 +01:00
der richter fe35baa88e mac/menu: rewrite menu bar in swift 2024-03-07 01:03:52 +01:00
der richter bbbd6e272c mac/app: remove unused function 2024-03-07 01:03:52 +01:00
der richter 86fa9b18a3 osdep/mac: make mac naming of files, folders and function consistent
rename all macOS namings (osx, macosx, macOS, macos, apple) to mac, to
make naming consistent.
2024-02-28 15:52:47 +01:00
der richter c7ff037fdd build: fix build when disabling cocoa-cb
the swift obj-c bridging header is only included when cocoa-cb is
enabled. cocoa-cb is not the only swift feature anymore and disabling
cocoa-cb leads to a runtime error that specific swift classes could not
be found.

include the swift obj-c bridging header in the case swift features are
enabled.
2024-02-27 14:04:30 +01:00
der richter a7c4a113b8 cocoa-cb: remove pre-allocation and initialise only when used
cocoa-cb was always pre-allocated in the Application itself because
libmpv needs to be set up before usage, an opengl context has to be set
and because it was decided mac specific code should be kept out of
libmpv.

this means that a completely working libmpv and opengl renderer was set
up even if it wasn't used. leading to unnecessary log message, resources
being used or reserved on the system that might not be used, triggering
of dedicated GPU unnecessarily and many other things.

even if not optimal, this wasn't the biggest problem since we only had
that one working vo on macOS. though now that we have a vulkan
gpu(-next) backend on macOS that was made the default, we always have
that dangling cocoa-cb instance, which is completely unnecessary.

move the cocoa-cb initialisation into libmpv preinit function and only
init cocoa-cb when we are a standalone App and cocoa-cb support is build
into.
2024-02-27 14:01:38 +01:00
nanahi ab3a63285a osdep/io: add mp_unlink()
unlink() was never wrapped in win32, so all usages of it were referring
the ANSI version of the function. This doesn't work properly for Windows
versions before 1903 (where the UTF-8 codepage is requested).

Fix this by adding mp_unlink() which wraps over _wunlink().
2024-02-25 14:30:20 +01:00
der richter 06ee5e9344 mac: code consistency changes 2024-02-24 20:04:16 +01:00
nanahi 84015959cc osdep/io: move I/O utility functions to misc/io_utils
The purpose of osdep/io is to provide a wrapper for POSIX I/O functions
on Windows. The last 2 functions are utility functions which don't serve
this purpose.
Move them to a separate file.
2024-02-23 21:35:57 +01:00
nanahi c36e051470 osdep/io: ignore 'x' mode for mp_fopen
fopen() with 'x' mode is a non-portable glibc extension, is currently
unused, and should not be used in order to maintain POSIX compatibility.
Thus there is no need for the Windows wrapper mp_fopen() to support it.
2024-02-23 21:35:43 +01:00
der richter d954646d29 various: make mentions of macOS consistent
change all mentions and variations of OSX, OS X, MacOSX, MacOS X, etc
consistent. use the official naming macOS.
2024-02-21 20:46:53 +01:00
Jose Maldonado aka Yukiteru 293532057e osdep/threads-posix: fix headers for OpenBSD build
In OpenBSD the compilation fail because osdep/threads-posix.h
need include pthread_np.h
2024-02-15 16:46:12 +00:00
der richter bba3d28781 mac/remote: simplify cover retrieval 2024-02-15 00:11:55 +01:00
der richter 45192d94d3 mac/remote: remove unnecessary nowPlayingInfo variable
no need to keep track of the nowPlayingInfo, MPNowPlayingInfoCenter
already provides the current info.
2024-02-15 00:11:55 +01:00
der richter e457cc260c mac/remote: add album and artist info 2024-02-15 00:11:55 +01:00
der richter c56be84675 mac/remote: add seek support
Fixes #11233
2024-02-15 00:11:55 +01:00
der richter 00efaeb428 mac/remote: add chapter title info 2024-02-15 00:11:55 +01:00
der richter ca8c61838e mac/remote: add media-title info
Fixes #11233
2024-02-15 00:11:55 +01:00
der richter 0a343369ba mac/remote: add playback rate info
also rate limit the position to update at max once per second.
2024-02-15 00:11:55 +01:00
der richter e23e158481 mac/remote: add duration and current position info
Fixes #11233
2024-02-15 00:11:55 +01:00
der richter 07a3bf0365 mac/remote: remove make current observer when stopped
the observer is registered on every call of the start function. this
could lead to several registered observers for the same event and
several calls to the make current function, even though we only need it
once per event.

properly remove the observer on stop, so we only ever have one observer
registered.
2024-02-15 00:11:55 +01:00
der richter de36f11fa8 mac/remote: replace command handler with generic handler function config
preparation for the upcoming changes for new functionality not related
to key handling.
2024-02-15 00:11:55 +01:00
der richter 05d0252a30 mac/remote: simplify repeatable key logic 2024-02-15 00:11:55 +01:00
der richter 0e556674dc mac/remote: move configs to initialiser for new MediaPlayer shorthands 2024-02-15 00:11:55 +01:00
der richter 1883f2f7a0 mac/remote: move class local struct and enum definition to extension
the class local struct and enum are moved to an extension to separate
their definition and usage.
2024-02-15 00:11:55 +01:00
der richter 80cde2671c mac/remote: use explicit struct instead of generic array for configs
making the config explicit gets rid of some optional unwrapping. also
rename some variables to better represent their values.
2024-02-15 00:11:55 +01:00
sfan5 ca5f7d2b4b osdep: fix infinite loop when cancelling subprocess
Due to the state of the other fds/pipes it cannot safely be assumed
that the loop breaks on its own.
2024-02-11 14:13:22 +01:00
nanahi 71598ca07e various: replace dead links in comments
Replace various dead links with live replacements or archives.
Less friction for anyone who wants to look up these references.
2024-02-11 04:01:24 +00:00
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