Commit Graph

1033 Commits

Author SHA1 Message Date
der richter e42a8d537f mac/log: fix use after free when freeing mpv handle
the mp_log is freed when the corresponding mpv_handle (ta_parent) is
freed in the EventHelper, though it could still be used from different
threads. instead don't use a ta_parent and manually free on manual
dereferencing. on app shutdown (memory cleanup) this is not called but
instead is freed by the usual cleanup and freeing.

the LogHelper is only able to be manually dereferenced in the AppHub,
so no race conditions are possible in all other cases (vo).in the AppHub
it's impossible to hit a race condition atm, because of how the init
process works and how/where the log is used. only manually forcing
logging in the exit process itself could theoretically trigger a use
after free.

Fixes #13823
2024-04-12 23:23:16 +02:00
der richter ee6794225d mac/vulkan: add support for frame timing via presentation feedback 2024-04-10 19:14:20 +02:00
Kacper Michajłow c389f9e75e win32: change fputs to fwrite wrapper
Removes mp_puts/mp_fputs and adds mp_fwrite.

In fact I wanted fwrite instead of puts, no need to make it more awkward
with the implicit new lines.

Fixes: fc55f355fc
2024-04-07 20:23:04 +02:00
Kacper Michajłow 6177aa7616 vo_tct: add synchronized output support
See-Also: https://gist.github.com/christianparpart/d8a62cc1ab659194337d73e399004036
2024-04-07 20:23:04 +02:00
Kacper Michajłow 0f85a380c3 terminal-win: add more control codes support in non-VT mode
And skip unsupported private sequences, instead of printing them.
2024-04-07 20:18:05 +02:00
der richter 2cbb13db9e mac/remote: use event type as key state for proper mapping in function
instead of using the MP_KEY events (Int32) and using a logical OR to
generate a key event for the mpv core, use the cocoa event type for key
states and pass those to the the function. in the function we properly
map those events to the right MP_KEY events.
2024-04-04 19:39:27 +02:00
der richter 70eba5e831 mac/apphub: fix opening several files at once via Finder or App icon
when dropping more than one file on the App icon or opening via Finder
the open(urls:) event might not pass all files at once in the array, but
may consecutivly call open(urls:) for each of the files or batched in
several arrays.

to fix this append any file passed to the open(urls:) event within 0.1
seconds of each other to the current playlist. the first event uses the
default behaviour.
2024-04-04 19:39:27 +02:00
der richter fe1de116f3 mac/app: add some verbose logging for app startup and file handling 2024-04-01 22:13:39 +02:00
der richter 9c0fc83f45 mac/apphub: only instantiate log and option when in Application mode
when in libmpv mode there is no need to for logging and reading options.
this also prevents possible race conditions with the usage and deinit of
the mpv_handler.
2024-04-01 22:13:39 +02:00
der richter 67c48ed922 mac/menu: remove redundant quit func and use identical command func 2024-04-01 22:13:39 +02:00
der richter 3c51497954 mac/app: cleanup and optimise App launch and termination
NSApp.terminate() is not a requirement to properly shut down a cocoa
App since it only calls exit() internally. though when not used the
cocoa termination events won't trigger, which we don't need. this
prevented us to exit with a proper exit code.

rework the whole termination logic to end up at one point where we can
return the exit code from the mpv_main function.

Fixes #7456
2024-04-01 22:13:39 +02:00
der richter d6c621b03b mac/apphub: move opening url into AppHub 2024-04-01 22:13:39 +02:00
der richter 2c7e4f5935 mac/app: use new open url App event to simplify open file event handling
this event has several advantages, it unifies the mpv:// url handling,
the dropping of files on the App icon and opening via finder into one
event, and it also lets us remove the file open workaround.

we had to keep track of opened files via the command line because the
event was also triggered by passed files on the command line, leading
to redundant load events.

the new event doesn't trigger from files passed via the command line
anymore.
2024-04-01 22:13:39 +02:00
der richter fc978eb9f2 mac/log: fallback to system logger if no mp_log is yet available
since cocoa is initialising mpv and does several things before the mpv
core does anything and the mpv_handle was passed to the App, this can be
used to log such things before the mpv logging is available. helpful for
debugging especially bundle related things.

the logger mapping looks a bit unintuitive but error is basically yellow
what our warning is and fatal is red what our error is.
2024-04-01 22:13:39 +02:00
der richter 7619cceb87 mac/app: rewrite App c main function, startup and termination in swift
also move main invocation into AppHub and completely delete the old
Application c implementation.
2024-04-01 22:13:39 +02:00
der richter b7c5b26d35 mac/app: rewrite Application class in swift 2024-04-01 22:13:39 +02:00
der richter ba45f2004f mac: cleanup swift bridge header imports and unify them 2024-03-29 14:20:40 +01:00
der richter 7c86074a15 mac/apphub: make DnD behaviour on bundle icon configurable
we just need to add a OptionHelper to the AppHub, options were already
tried to read from the optional OptionHelper.
2024-03-29 14:20:40 +01:00
der richter ed0587692f mac/log: rename log functions and cleanup class 2024-03-29 14:20:40 +01:00
der richter ceaabb7b98 mac: use LogHelper directly instead of mp_log 2024-03-29 14:20:40 +01:00
der richter e7df95b10d mac: rename mpvHandle to mpv 2024-03-29 14:20:40 +01:00
der richter e71e340b77 mac: remove now unnecessary objective-c forwarding 2024-03-29 14:20:40 +01:00
der richter 6debb22a0c mac/apphub: move cocoa-cb into AppHub 2024-03-29 14:20:40 +01:00
der richter 1bc680d32a mac/apphub: move menu bar into AppHub 2024-03-29 14:20:40 +01:00
der richter e2bc1e5f9b mac/app: remove unused Application flag 2024-03-29 14:20:40 +01:00
der richter 23db34dd6d mac/apphub: move mac options into AppHub 2024-03-29 14:20:40 +01:00
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